1- // Install modules
2- #module nuget : ? package = Cake . DotNetTool . Module & version = 0.3 .0
3-
41// Install tools
52#tool nuget : ? package= NUnit . ConsoleRunner & version = 3.4 .0
63
74// Install .NET Core Global tools.
8- #tool "dotnet: https : //api.nuget.org/v3/index.json ?package=GitVersion.Tool&version=5.0.1 "
5+ #tool "dotnet:?package=GitVersion.Tool&version=5.9.0 "
96
107///////////////////////////////////////////////////////////////////////////////
118// ARGUMENTS
@@ -18,7 +15,7 @@ var configuration = Argument("configuration", "Release");
1815// PARAMETERS
1916//////////////////////////////////////////////////////////////////////
2017
21- DotNetCoreMSBuildSettings msBuildSettings = null ;
18+ DotNetMSBuildSettings msBuildSettings = null ;
2219string version = null ,
2320 semVersion = null ,
2421 milestone = null ;
@@ -54,10 +51,12 @@ Setup(ctx =>
5451
5552 Information ( "Calculated Semantic Version: {0}" , semVersion ) ;
5653
57- msBuildSettings = new DotNetCoreMSBuildSettings ( )
54+ msBuildSettings = new DotNetMSBuildSettings ( )
5855 . WithProperty ( "Version" , semVersion )
5956 . WithProperty ( "AssemblyVersion" , version )
60- . WithProperty ( "FileVersion" , version ) ;
57+ . WithProperty ( "FileVersion" , version )
58+ . WithProperty ( "ContinuousIntegrationBuild" , BuildSystem . IsLocalBuild ? bool . FalseString : bool . TrueString ) ;
59+
6160
6261 if ( ! IsRunningOnWindows ( ) )
6362 {
@@ -107,16 +106,16 @@ Task("Clean")
107106Task ( "Restore" )
108107 . IsDependentOn ( "Clean" )
109108 . Does ( ( ) => {
110- DotNetCoreRestore ( "./LitJSON.sln" ,
111- new DotNetCoreRestoreSettings { MSBuildSettings = msBuildSettings }
109+ DotNetRestore ( "./LitJSON.sln" ,
110+ new DotNetRestoreSettings { MSBuildSettings = msBuildSettings }
112111 ) ;
113112} ) ;
114113
115114Task ( "Build" )
116115 . IsDependentOn ( "Restore" )
117116 . Does ( ( ) => {
118- DotNetCoreBuild ( "./LitJSON.sln" ,
119- new DotNetCoreBuildSettings {
117+ DotNetBuild ( "./LitJSON.sln" ,
118+ new DotNetBuildSettings {
120119 Configuration = configuration ,
121120 MSBuildSettings = msBuildSettings ,
122121 ArgumentCustomization = args => args . Append ( "--no-restore" )
@@ -127,10 +126,10 @@ Task("Build")
127126Task ( "Test" )
128127 . IsDependentOn ( "Build" )
129128 . Does ( ( ) => {
130- DotNetCoreTest ( "./test/LitJSON.Tests.csproj" ,
131- new DotNetCoreTestSettings {
129+ DotNetTest ( "./test/LitJSON.Tests.csproj" ,
130+ new DotNetTestSettings {
132131 Configuration = configuration ,
133- Framework = "netcoreapp2 .0" ,
132+ Framework = "net6 .0" ,
134133 NoBuild = true ,
135134 ArgumentCustomization = args => args . Append ( "--no-restore" )
136135 }
@@ -143,20 +142,20 @@ Task("Test")
143142
144143Task ( "Test-SourceLink" )
145144 . IsDependentOn ( "Build" )
146- . WithCriteria ( IsRunningOnWindows ( ) )
145+ . WithCriteria ( IsRunningOnWindows ( ) && AppVeyor . IsRunningOnAppVeyor )
147146 . Does ( ( ) => {
148147 foreach ( var asssembly in GetFiles ( "./src/LitJson/bin/" + configuration + "/**/*.dll" ) )
149148 {
150- DotNetCoreTool ( litjsonProjectPath . FullPath , "sourcelink" , $ "test { asssembly } ") ;
149+ DotNetTool ( litjsonProjectPath . FullPath , "sourcelink" , $ "test { asssembly } ") ;
151150 }
152151} ) ;
153152
154153Task ( "Package" )
155154 . IsDependentOn ( "Test" )
156155 . IsDependentOn ( "Test-SourceLink" )
157156 . Does ( ( ) => {
158- DotNetCorePack ( litjsonProjectPath . FullPath ,
159- new DotNetCorePackSettings {
157+ DotNetPack ( litjsonProjectPath . FullPath ,
158+ new DotNetPackSettings {
160159 Configuration = configuration ,
161160 NoBuild = true ,
162161 IncludeSymbols = true ,
@@ -197,8 +196,8 @@ Task("Publish-MyGet")
197196
198197 foreach ( var package in ( GetFiles ( "./artifacts/nuget/*.nupkg" ) - GetFiles ( "./artifacts/nuget/*.symbols.nupkg" ) ) )
199198 {
200- DotNetCoreNuGetPush ( package . FullPath ,
201- new DotNetCoreNuGetPushSettings {
199+ DotNetNuGetPush ( package . FullPath ,
200+ new DotNetNuGetPushSettings {
202201 ApiKey = apiKey ,
203202 Source = apiUrl
204203 }
@@ -215,19 +214,50 @@ Task("Publish-NuGet")
215214 // Resolve the API key.
216215 var apiKey = EnvironmentVariable ( "NUGET_API_KEY" ) ;
217216 if ( string . IsNullOrEmpty ( apiKey ) ) {
218- throw new InvalidOperationException ( "Could not resolve MyGet API key." ) ;
217+ throw new InvalidOperationException ( "Could not resolve NuGet API key." ) ;
219218 }
220219
221220 // Resolve the API url.
222221 var apiUrl = EnvironmentVariable ( "NUGET_API_URL" ) ;
223222 if ( string . IsNullOrEmpty ( apiUrl ) ) {
224- throw new InvalidOperationException ( "Could not resolve MyGet API url." ) ;
223+ throw new InvalidOperationException ( "Could not resolve NuGet API url." ) ;
224+ }
225+
226+ foreach ( var package in ( GetFiles ( "./artifacts/nuget/*.nupkg" ) - GetFiles ( "./artifacts/nuget/*.symbols.nupkg" ) ) )
227+ {
228+ DotNetNuGetPush ( package . FullPath ,
229+ new DotNetNuGetPushSettings {
230+ ApiKey = apiKey ,
231+ Source = apiUrl
232+ }
233+ ) ;
234+ }
235+ } ) ;
236+
237+ Task ( "Push-GitHub-Packages" )
238+ . IsDependentOn ( "Package" )
239+ . WithCriteria (
240+ GitHubActions . IsRunningOnGitHubActions &&
241+ ! GitHubActions . Environment . PullRequest . IsPullRequest &&
242+ IsRunningOnWindows ( ) )
243+ . Does ( ( ) => {
244+
245+ // Resolve the API key.
246+ var apiKey = EnvironmentVariable ( "GH_PACKAGES_NUGET_APIKEY" ) ;
247+ if ( string . IsNullOrEmpty ( apiKey ) ) {
248+ throw new InvalidOperationException ( "Could not resolve GitHub API key." ) ;
249+ }
250+
251+ // Resolve the API url.
252+ var apiUrl = EnvironmentVariable ( "GH_PACKAGES_NUGET_SOURCE" ) ;
253+ if ( string . IsNullOrEmpty ( apiUrl ) ) {
254+ throw new InvalidOperationException ( "Could not resolve GitHub API url." ) ;
225255 }
226256
227257 foreach ( var package in ( GetFiles ( "./artifacts/nuget/*.nupkg" ) - GetFiles ( "./artifacts/nuget/*.symbols.nupkg" ) ) )
228258 {
229- DotNetCoreNuGetPush ( package . FullPath ,
230- new DotNetCoreNuGetPushSettings {
259+ DotNetNuGetPush ( package . FullPath ,
260+ new DotNetNuGetPushSettings {
231261 ApiKey = apiKey ,
232262 Source = apiUrl
233263 }
@@ -240,6 +270,9 @@ Task("AppVeyor")
240270 . IsDependentOn ( "Publish-MyGet" )
241271 . IsDependentOn ( "Publish-NuGet" ) ;
242272
273+ Task ( "GitHub-Actions" )
274+ . IsDependentOn ( "Push-GitHub-Packages" ) ;
275+
243276Task ( "Default" )
244277 . IsDependentOn ( "Package" ) ;
245278
0 commit comments