1
1
#tool "nuget:?package=GitVersion.CommandLine"
2
2
3
+ using System . Text . RegularExpressions ;
4
+
3
5
//////////////////////////////////////////////////////////////////////
4
6
// ARGUMENTS
5
7
//////////////////////////////////////////////////////////////////////
@@ -10,6 +12,11 @@ var pushPackages = Argument("PushPackages", "false") == "true";
10
12
bool isPrerelease = false ;
11
13
GitVersion versionInfo = null ;
12
14
15
+ var projectsToBuild = new string [ ] {
16
+ "./src/Cofoundry.Plugins.Azure/Cofoundry.Plugins.Azure.csproj" ,
17
+ } ;
18
+
19
+
13
20
//////////////////////////////////////////////////////////////////////
14
21
// PREPARATION
15
22
//////////////////////////////////////////////////////////////////////
@@ -29,12 +36,6 @@ Task("Clean")
29
36
CleanDirectories ( "./src/**/obj/" + configuration ) ;
30
37
} ) ;
31
38
32
- Task ( "Restore-NuGet-Packages" )
33
- . IsDependentOn ( "Clean" )
34
- . Does ( ( ) =>
35
- {
36
- NuGetRestore ( "./src/Cofoundry.Plugins.Azure.sln" ) ;
37
- } ) ;
38
39
39
40
Task ( "Patch-Assembly-Version" )
40
41
. IsDependentOn ( "Clean" )
@@ -44,49 +45,65 @@ Task("Patch-Assembly-Version")
44
45
UpdateAssemblyInfo = false
45
46
} ) ;
46
47
47
- Information ( "Building version {0} of Cofoundry.Plugins.Azure. " , versionInfo . InformationalVersion ) ;
48
+ Information ( "Building version {0} of Cofoundry." , versionInfo . InformationalVersion ) ;
48
49
49
50
isPrerelease = ! string . IsNullOrEmpty ( versionInfo . PreReleaseNumber ) ;
50
51
51
- var file = "./src/SolutionInfo.cs" ;
52
- CreateAssemblyInfo ( file , new AssemblyInfoSettings {
53
- Version = versionInfo . AssemblySemVer ,
54
- FileVersion = versionInfo . MajorMinorPatch + ".0" ,
55
- InformationalVersion = versionInfo . InformationalVersion ,
56
- Copyright = "Copyright © Cofoundry.org " + DateTime . Now . Year
57
- } ) ;
52
+ // Patch the version number so it's picked up when dependent projects are references
53
+ // as nuget dependencies. Can't find a better way to do this.
54
+ // Also this needs to run before DotNetCoreRestore for some reason (cached?)
55
+ var file = MakeAbsolute ( File ( "./src/Directory.Build.props" ) ) ;
56
+ var xml = System . IO . File . ReadAllText ( file . FullPath , Encoding . UTF8 ) ;
57
+ xml = Regex . Replace ( xml , @"(<Version>)(.+)(<\/Version>)" , "${1}" + versionInfo . NuGetVersion + "${3}" ) ;
58
+ System . IO . File . WriteAllText ( file . FullPath , xml , Encoding . UTF8 ) ;
59
+ } ) ;
60
+
61
+ Task ( "Restore-NuGet-Packages" )
62
+ . IsDependentOn ( "Patch-Assembly-Version" )
63
+ . Does ( ( ) =>
64
+ {
65
+ foreach ( var projectToBuild in projectsToBuild )
66
+ {
67
+ DotNetCoreRestore ( projectToBuild ) ;
68
+ }
58
69
} ) ;
59
70
60
71
Task ( "Build" )
61
72
. IsDependentOn ( "Restore-NuGet-Packages" )
62
- . IsDependentOn ( "Patch-Assembly-Version" )
63
73
. Does ( ( ) =>
64
74
{
65
- if ( IsRunningOnWindows ( ) )
75
+
76
+ var settings = new DotNetCoreBuildSettings
77
+ {
78
+ Configuration = configuration ,
79
+ ArgumentCustomization = args => args
80
+ . Append ( "/p:NuGetVersion=" + versionInfo . NuGetVersion )
81
+ . Append ( "/p:AssemblyVersion=" + versionInfo . AssemblySemVer )
82
+ . Append ( "/p:FileVersion=" + versionInfo . MajorMinorPatch + ".0" )
83
+ . Append ( "/p:InformationalVersion=" + versionInfo . InformationalVersion )
84
+ . Append ( "/p:Copyright=" + "\" Copyright © Cofoundry.org " + DateTime . Now . Year + "\" " )
85
+ } ;
86
+
87
+ foreach ( var projectToBuild in projectsToBuild )
66
88
{
67
- // Use MSBuild
68
- MSBuild ( "./src/Cofoundry.Plugins.Azure.sln" , settings => settings . SetConfiguration ( configuration ) ) ;
89
+ DotNetCoreBuild ( projectToBuild , settings ) ;
69
90
}
70
91
} ) ;
71
92
72
93
Task ( "Pack" )
73
94
. IsDependentOn ( "Build" )
74
95
. Does ( ( ) =>
75
96
{
76
- var nugetFilePaths = GetFiles ( "./src/Cofoundry.*/*.nuspec" ) ;
77
-
78
- var nuGetPackSettings = new NuGetPackSettings
79
- {
80
- Version = versionInfo . NuGetVersion ,
81
- OutputDirectory = nugetPackageDir ,
82
- Verbosity = NuGetVerbosity . Detailed ,
83
- ArgumentCustomization = args => args . Append ( "-Prop Configuration=" + configuration )
84
- } ;
97
+ var settings = new DotNetCorePackSettings
98
+ {
99
+ Configuration = configuration ,
100
+ OutputDirectory = "./artifacts/" ,
101
+ NoBuild = true
102
+ } ;
85
103
86
- foreach ( var path in nugetFilePaths )
104
+ foreach ( var projectToBuild in projectsToBuild )
87
105
{
88
- Information ( "Packing:" + path ) ;
89
- NuGetPack ( path , nuGetPackSettings ) ;
106
+ DotNetCorePack ( projectToBuild , settings ) ;
90
107
}
91
108
} ) ;
92
109
0 commit comments