forked from Azure/azure-sdk-for-net
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nuget.targets
179 lines (136 loc) · 7.59 KB
/
nuget.targets
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--
NuGet Targets - Windows Azure SDK for .NET
-->
<!--
Import all nested NuGet property projects, named as *.nuget.proj to
differentiate from the .nuproj system (which we may want to move to in the
future)
-->
<Import Project="*\**\*.nuget.proj"/>
<PropertyGroup>
<BaselineReleaseNotes>PREVIEW RELEASE</BaselineReleaseNotes>
</PropertyGroup>
<!--
Windows Azure SDK for .NET - NuGet Package Guide
- - -
The NuGet Package ID is the Include="..." portion of the package
authoring work.
Required elements:
- - -
PackageVersion
A NuGet version. We follow SemVer. Learn more by checking
this page out:
http://docs.nuget.org/docs/reference/versioning
This is the version that will be used for the package.
Anything after a number indicates a PRE-RELEASE package
that is treated differently by NuGet.
Common suffixes then include -preview for Windows Azure.
Nightly and one-off builds that may be published to an
alternative NuGet server such as MyGet may override the
BuildVersionSuffix property to append an additional
string value to the version.
Optional elements:
- - -
Publish
true/false
A value indicating whether to include the package in the
publishing process to a NuGet server.
True by default, this optional element can be used to
keep built packages off of NuGet. This can be used for
management libraries that are only used as internal
dependencies today for projects like PowerShell.
As components reach maturity for a public Preview for
developers, this should then be flipped to share the
goods with our customers.
SkipSymbolSourcePackage
true/false
Designed for packages that are for grouping only and do
not contain libraries, when true this property will make
sure that the -Symbols property is not passed to NuGet
while packing the project.
Also, we won't attempt to push a symbol/source package to
the cloud for debugging use.
-->
<!--
General NuGet packaging properties
-->
<PropertyGroup>
<NuGetCommand>.nuget\NuGet.exe</NuGetCommand>
<PackageOutputDir>binaries\packages</PackageOutputDir>
<NuGetVerbosity>normal</NuGetVerbosity>
<PublishSymbolSourcePackages>true</PublishSymbolSourcePackages>
</PropertyGroup>
<ItemGroup>
<NuSpecReplacementTokens Include="BASELINE_RELEASE_NOTES">
<Value>$(BaselineReleaseNotes)</Value>
</NuSpecReplacementTokens>
</ItemGroup>
<UsingTask AssemblyFile="tools\Microsoft.WindowsAzure.Build.Tasks.dll" TaskName="RegexReplacementTask" />
<Target Name="BuildDynamicNuSpecs"
DependsOnTargets="GetGeneratedBuildDate; EnsureBinariesFolderExists">
<ItemGroup>
<NuspecFilesToUpdate Include="%(SdkNuGetPackage.Folder)%(SdkNuGetPackage.Identity).nuspec" />
</ItemGroup>
<Error Text="NuGet specification %(NuspecFilesToUpdate.Identity) not found."
Condition="!Exists(%(NuspecFilesToUpdate.Identity))" />
<!-- First replace any string tokens, storing the output in the binaries
folder instead of doing a destructive replacement. -->
<RegexReplacementTask Files="@(NuspecFilesToUpdate)"
OutputDir="binaries\packages\specs\"
Find="__%(NuSpecReplacementTokens.Identity)__"
Replace="%(NuSpecReplacementTokens.Value)"
LogReplacement="false" />
<!-- Second, use the new files as destructive replacement targets. -->
<ItemGroup>
<NuspecFilesToUpdate2 Include="binaries\packages\specs\*.nuspec" />
</ItemGroup>
<RegexReplacementTask Files="@(NuspecFilesToUpdate2)"
Find="__VERSION_%(SdkNuGetPackage.Identity)__"
Replace="%(SdkNuGetPackage.PackageVersion)$(BuildVersionSuffix)$(AdditionalVersionSuffix)"
LogReplacement="false" />
<Message Text="Created dynamic nuspec %(NuspecFilesToUpdate2.Identity)" />
</Target>
<Target Name="ListPackages">
<Message Text="%(SdkNuGetPackage.Identity) %(SdkNuGetPackage.PackageVersion) %(SdkNuGetPackage.Folder)" />
</Target>
<Target Name="EnsureBinariesFolderExists">
<MakeDir Directories="binaries" Condition="!Exists('binaries')" />
<MakeDir Directories="binaries\packages" Condition="!Exists('binaries\packages')" />
<MakeDir Directories="binaries\packages\specs" Condition="!Exists('binaries\packages\specs')" />
</Target>
<!--
Build NuGet packages
-->
<Target Name="BuildPackages"
DependsOnTargets="EnsureBinariesFolderExists; BuildDynamicNuSpecs">
<Message Text="Generating NuGet library & symbols + source packages" Importance="high" />
<Exec Condition=" '%(SdkNuGetPackage.SkipSymbolSourcePackage)' != 'true' "
Command="$(NuGetCommand) pack -BasePath .\src\ -Verbosity $(NuGetVerbosity) "binaries\packages\specs\%(SdkNuGetPackage.Identity).nuspec" -Version %(SdkNuGetPackage.PackageVersion)$(BuildVersionSuffix)$(AdditionalVersionSuffix) -OutputDirectory "$(PackageOutputDir)" -Symbols" />
<Message Text="Generating NuGet packages without symbol + source packages" Importance="high" />
<Exec Condition=" '%(SdkNuGetPackage.SkipSymbolSourcePackage)' == 'true' "
Command="$(NuGetCommand) pack -BasePath .\src\ -Verbosity $(NuGetVerbosity) "binaries\packages\specs\%(SdkNuGetPackage.Identity).nuspec" -Version %(SdkNuGetPackage.PackageVersion)$(BuildVersionSuffix)$(AdditionalVersionSuffix) -OutputDirectory "$(PackageOutputDir)"" />
</Target>
<Target Name="PublishPackagesOnly">
<Error Condition=" '$(NuGetKey)' == '' " Text="You must provide the NuGetKey parameter to the build: /p:NuGetKey=YOUR_PUBLISHING_KEY" />
<PropertyGroup>
<ActualSource Condition=" '$(NuGetPublishingSource)' == '' "></ActualSource>
<ActualSource Condition=" '$(NuGetPublishingSource)' != '' "> -Source $(NuGetPublishingSource)</ActualSource>
</PropertyGroup>
<Message Importance="high" Text="Publishing NuGet packages to the cloud at $(NuGetPublishingSource)" />
<Exec Command="$(NuGetCommand) push "$(PackageOutputDir)\%(SdkNuGetPackage.Identity).%(SdkNuGetPackage.PackageVersion)$(BuildVersionSuffix)$(AdditionalVersionSuffix).nupkg" $(NuGetKey)$(ActualSource)"
IgnoreExitCode="true"
Condition=" '%(SdkNuGetPackage.Publish)' != 'false' " />
<Message Importance="high" Text="Publishing NuGet symbol & source packages to the cloud at $(NuGetSymbolPublishingSource)"
Condition=" $(NuGetSymbolPublishingSource) != '' "/>
<Exec Command="$(NuGetCommand) push "$(PackageOutputDir)\%(SdkNuGetPackage.Identity).%(SdkNuGetPackage.PackageVersion)$(BuildVersionSuffix)$(AdditionalVersionSuffix).Symbols.nupkg" $(NuGetKey) -Source $(NuGetSymbolPublishingSource)"
Condition=" $(NuGetSymbolPublishingSource) != '' And '%(SdkNuGetPackage.Publish)' != 'false' And '%(SdkNuGetPackage.SkipSymbolSourcePackage)' != 'true' And '$(PublishSymbolSourcePackages)' == 'true' "
IgnoreExitCode="true"
ContinueOnError="true" />
<Message Text="Not publishing package %(SdkNuGetPackage.Identity) as Publish is set to 'false' for the component."
Condition=" '%(SdkNuGetPackage.Publish)' == 'false' " />
<Warning Text="Symbol/source packages are not being pushed. The PublishSymbolSourcePackages property is not set to true."
Condition=" '$(PublishSymbolSourcePackages)' != 'true' " />
</Target>
</Project>