1- #tool "nuget :?package=GitVersion.CommandLine &version=4.0.0 "
2- #tool "nuget:?package=nuget.commandline &version=5.3 .0"
1+ #tool "dotnet :?package=GitVersion.Tool &version=5.8.1 "
2+ #tool "nuget:?package=NuGet.CommandLine &version=5.11 .0"
33
44var target = Argument ( "target" , "Default" ) ;
55var nugetApiKey = Argument ( "nugetApiKey" , EnvironmentVariable ( "nugetApiKey" ) ) ;
@@ -9,9 +9,13 @@ var nugetApiKey = Argument("nugetApiKey", EnvironmentVariable("nugetApiKey"));
99/////////////////////////////////////////////////////////////////////
1010var solution = "./WebOptimizer.Dotless.sln" ;
1111var project = "./src/WebOptimizer.Dotless.csproj" ;
12- var outputDir = "./buildArtifacts/" ;
13- var outputDirNuget = outputDir + "NuGet/" ;
14- var testResultsPath = System . IO . Path . Combine ( System . IO . Path . GetFullPath ( outputDir ) , "TestResults.xml" ) ;
12+ var outputDirRoot = new DirectoryPath ( "./buildArtifacts/" ) . MakeAbsolute ( Context . Environment ) ;
13+ var outputDirPublished = outputDirRoot . Combine ( "Published" ) ;
14+ var outputDirTemp = outputDirRoot . Combine ( "Temp" ) ;
15+ var packageOutputDir = outputDirPublished . Combine ( "Package" ) ;
16+
17+ var outputDirTests = outputDirTemp . Combine ( "Tests/" ) ;
18+
1519var nugetPublishFeed = "https://api.nuget.org/v3/index.json" ;
1620
1721
@@ -23,14 +27,12 @@ Task("Clean")
2327 . Description ( "Removes the output directory" )
2428 . Does ( ( ) => {
2529
26- if ( DirectoryExists ( outputDir ) )
27- {
28- DeleteDirectory ( outputDir , new DeleteDirectorySettings {
30+ EnsureDirectoryDoesNotExist ( outputDirRoot , new DeleteDirectorySettings {
2931 Recursive = true ,
3032 Force = true
31- } ) ;
32- }
33- CreateDirectory ( outputDir ) ;
33+ } ) ;
34+ CreateDirectory ( outputDirRoot ) ;
35+ CreateDirectory ( outputDirPublished ) ;
3436} ) ;
3537
3638GitVersion versionInfo = null ;
@@ -50,48 +52,41 @@ Task("Build")
5052 . IsDependentOn ( "Version" )
5153 . Does ( ( ) => {
5254
53- var settings = new DotNetCoreBuildSettings {
54- Configuration = "Release" ,
55- ArgumentCustomization = args => args . Append ( "/p:SemVer=" + versionInfo . NuGetVersionV2 + " /p:SourceLinkCreate=true" )
56- } ;
55+ var msBuildSettings = new DotNetMSBuildSettings ( )
56+ {
57+ Version = versionInfo . AssemblySemVer ,
58+ InformationalVersion = versionInfo . InformationalVersion ,
59+ PackageVersion = versionInfo . NuGetVersionV2
60+ } . WithProperty ( "PackageOutputPath" , packageOutputDir . FullPath ) ;
5761
58- DotNetCoreBuild ( project , settings ) ;
62+ var settings = new DotNetBuildSettings {
63+ Configuration = "Release" ,
64+ MSBuildSettings = msBuildSettings
65+ } ;
66+
67+ DotNetBuild ( project , settings ) ;
5968 } ) ;
6069
6170Task ( "Test" )
6271 . IsDependentOn ( "Build" )
6372 . Does ( ( ) =>
6473 {
65- var settings = new DotNetCoreTestSettings {
66- Logger = "trx;logfilename=" + testResultsPath
74+ var settings = new DotNetTestSettings {
75+ Loggers = new [ ] { "trx;" } ,
76+ ResultsDirectory = outputDirTests ,
77+ NoBuild = true
6778 } ;
6879
69- DotNetCoreTest ( "./test/WebOptimizer.Dotless.Test.csproj" , settings ) ;
70- } ) ;
71-
72-
73- Task ( "Pack" )
74- . IsDependentOn ( "Test" )
75- . IsDependentOn ( "Version" )
76- . Does ( ( ) => {
77-
78- var packSettings = new DotNetCorePackSettings
79- {
80- Configuration = "Release" ,
81- OutputDirectory = outputDirNuget ,
82- ArgumentCustomization = args => args . Append ( "/p:PackageVersion=" + versionInfo . NuGetVersionV2 + " /p:SourceLinkCreate=true" )
83- } ;
84-
85- DotNetCorePack ( project , packSettings ) ;
80+ DotNetTest ( "./test/WebOptimizer.Dotless.Test.csproj" , settings ) ;
8681 } ) ;
8782
8883Task ( "Publish" )
89- . IsDependentOn ( "Pack " )
84+ . IsDependentOn ( "Test " )
9085 . Description ( "Pushes the created NuGet packages to nuget.org" )
9186 . Does ( ( ) => {
9287
9388 // Get the paths to the packages.
94- var packages = GetFiles ( outputDirNuget + "*.nupkg" ) ;
89+ var packages = GetFiles ( packageOutputDir . CombineWithFilePath ( "*.nupkg" ) . FullPath ) ;
9590
9691 // Push the package.
9792 NuGetPush ( packages , new NuGetPushSettings {
0 commit comments