Skip to content

Commit f354a72

Browse files
committed
[Build] Allow to push NuGet package based on property. Add safe support for build number for dev packages
1 parent 9f2f526 commit f354a72

File tree

1 file changed

+28
-33
lines changed

1 file changed

+28
-33
lines changed

Build/SharpDX.build

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,19 @@
2020
// THE SOFTWARE.
2121
-->
2222
<!-- Common Settings used by SharpDX projects -->
23-
<Project DefaultTargets="PackageDev" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
24-
23+
<Project DefaultTargets="Package" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2524
<PropertyGroup>
2625
<SharpDXRepo>$(MSBuildThisFileDirectory)..</SharpDXRepo>
27-
<SharDXNugetPackages>$(MSBuildThisFileDirectory)Packages</SharDXNugetPackages>
28-
<GitExe>"C:\Program Files (x86)\Git\bin\git.exe"</GitExe>
26+
<SharpDXNugetPackageDir>$(MSBuildThisFileDirectory)Packages</SharpDXNugetPackageDir>
2927
<ExtensionTasksPath>$(SharpDXRepo)\External\MSBuildExtensionPack\</ExtensionTasksPath>
3028
<BuildSignedSharpDX>true</BuildSignedSharpDX>
3129
<SharedAssemblyInfoFilePath>$(SharpDXRepo)\Source\SharedAssemblyInfo.cs</SharedAssemblyInfoFilePath>
3230
<SharedAssemblyInfo>$([System.IO.File]::ReadAllText($(SharedAssemblyInfoFilePath)))</SharedAssemblyInfo>
33-
<SharpDXAssemblyPostFixVersion>-beta01</SharpDXAssemblyPostFixVersion>
31+
<SharpDXPackagingDevName Condition="'$(SharpDXPackagingDevName)' == ''">alpha</SharpDXPackagingDevName>
32+
<SharpDXBuildNumber Condition="'$(SharpDXBuildNumber)' == ''">1</SharpDXBuildNumber>
33+
<SharpDXAssemblyPostFixVersion Condition="'$(SharpDXPackagingDev)' == 'true'">-$(SharpDXPackagingDevName)$([System.String]::Format('{0:000}', $([MSBuild]::Add($(SharpDXBuildNumber), 0))))</SharpDXAssemblyPostFixVersion>
3434
<SharpDXAssemblyVersion>$([System.Text.RegularExpressions.Regex]::Match($(SharedAssemblyInfo), `AssemblyVersion\("(.*)"`).Groups[1].Value)$(SharpDXAssemblyPostFixVersion)</SharpDXAssemblyVersion>
35-
<SharpDXDevZip>$(MSBuildThisFileDirectory)\SharpDX-SDK-LatestDev.exe</SharpDXDevZip>
36-
<SharpDXReleaseZip>$(MSBuildThisFileDirectory)\SharpDX-SDK-$(SharpDXAssemblyVersion).exe</SharpDXReleaseZip>
37-
<SharpDXLocalUpload>C:\inetpub\wwwroot\sharpdx\upload</SharpDXLocalUpload>
35+
<SharpDXZipName>$(MSBuildThisFileDirectory)\SharpDX-SDK-$(SharpDXAssemblyVersion).exe</SharpDXZipName>
3836
</PropertyGroup>
3937

4038
<Import Project="$(ExtensionTasksPath)MSBuild.ExtensionPack.tasks"/>
@@ -45,33 +43,41 @@
4543
<Message Importance="high" Text="Use parameter /t:Pre-Build;Build to build SharpDX assemblies for non WP8 platforms. And /t:BuildForVS2012 for WP8"/>
4644
</Target>
4745

48-
<Target Name="PackageDev">
49-
<CallTarget Targets="Build"/>
46+
<Target Name="Package">
47+
<Message Importance="High" Text="Building SharpDX $(SharpDXAssemblyVersion)"/>
48+
<CallTarget Targets="Build"/>
5049
<CallTarget Targets="Nuget"/>
5150
<CallTarget Targets="ZipBuild"/>
51+
<CallTarget Condition="'$(SharpDXNugetPush)' == 'true'" Targets="NugetPush"/>
52+
</Target>
53+
54+
<Target Name="Build">
55+
<!--Build all targets / platforms-->
56+
<Exec Command="RMDIR /Q /S $(SharpDXRepo)\Bin"/>
57+
<MSBuild Targets="Clean;Build" Projects="$(SharpDXRepo)\SharpDX-Desktop.sln" Properties="Configuration=Release;Platform=Any CPU;SharpDXSign=true"/>
58+
<MSBuild Targets="Clean;Build" Projects="$(SharpDXRepo)\SharpDX-StoreApp.sln" Properties="Configuration=Release;Platform=Any CPU;SharpDXSign=true"/>
5259
</Target>
5360

5461
<Target Name="Nuget">
55-
<Exec Command="RMDIR /Q /S $(SharDXNugetPackages)"/>
56-
<MakeDir Directories="$(SharDXNugetPackages)"/>
62+
<Exec Command="RMDIR /Q /S $(SharpDXNugetPackageDir)"/>
63+
<MakeDir Directories="$(SharpDXNugetPackageDir)"/>
5764
<ItemGroup>
5865
<SharpDXNuspecs Include="$(SharpDXRepo)\Source\**\*.nuspec"/>
5966
</ItemGroup>
60-
<Exec Command="nuget.exe pack -OutputDirectory $(SharDXNugetPackages) -Properties version=$(SharpDXAssemblyVersion) -Symbols %(SharpDXNuspecs.Identity)"/>
67+
<Exec Command="nuget.exe pack -OutputDirectory $(SharpDXNugetPackageDir) -Properties version=$(SharpDXAssemblyVersion) -Symbols %(SharpDXNuspecs.Identity)"/>
6168
</Target>
6269

6370
<Target Name="NugetPush">
6471
<ItemGroup>
65-
<SharpDXNupkg Include="$(SharDXNugetPackages)\*.nupkg"/>
72+
<SharpDXNupkg Include="$(SharpDXNugetPackageDir)\*.nupkg"/>
6673
</ItemGroup>
67-
<Exec Command="nuget.exe push %(SharpDXNupkg.Identity)" IgnoreExitCode="true"/>
68-
</Target>
69-
70-
<Target Name="Build">
71-
<!--Build all targets / platforms-->
72-
<Exec Command="RMDIR /Q /S $(SharpDXRepo)\Bin"/>
73-
<MSBuild Targets="Clean;Build" Projects="$(SharpDXRepo)\SharpDX-Desktop.sln" Properties="Configuration=Release;Platform=Any CPU;SharpDXSign=true"/>
74-
<MSBuild Targets="Clean;Build" Projects="$(SharpDXRepo)\SharpDX-StoreApp.sln" Properties="Configuration=Release;Platform=Any CPU;SharpDXSign=true"/>
74+
<Error Condition="'$(SharpDXNugetApiKey)' == ''" Text="SharpDXNugetApiKey env variable is required when pushing nuget package"/>
75+
<Exec Command="nuget.exe push -ApiKey $(SharpDXNugetApiKey) %(SharpDXNupkg.Identity)" IgnoreExitCode="true"/>
76+
</Target>
77+
78+
<Target Name="ZipBuild">
79+
<Delete Files="$(SharpDXZipName)"/>
80+
<Exec WorkingDirectory="$(SharpDXRepo)" Command='$(SharpDXRepo)\External\7-Zip\7z.exe a -sfx7z.sfx -xr!External -xr!*.check -xr!*.pdb -xr!*.lib -xr!*.pri -xr!*.exp $(SharpDXZipName) Bin\*\*.* License.txt ReleaseNotes.md Readme.md'/>
7581
</Target>
7682

7783
<!--Custom task for checking certification result (fail or pass), the project is excluded from solution build - needs to be rebuilt manually when needed-->
@@ -122,15 +128,4 @@
122128
<VerifyCertificationResultTask File="$(SharpDXRepo)\Source\CertificationTests\Results\Test.WinRT.xml" />
123129
<VerifyCertificationResultTask File="$(SharpDXRepo)\Source\CertificationTests\Results\Test.WP81.xml" />
124130
</Target>
125-
126-
<Target Name="ZipBuild">
127-
<Delete Files="$(SharpDXDevZip)"/>
128-
<Exec WorkingDirectory="$(SharpDXRepo)" Command='$(SharpDXRepo)\External\7-Zip\7z.exe a -sfx7z.sfx -xr!External -xr!*.check -xr!*.pdb -xr!*.lib -xr!*.pri -xr!*.exp $(SharpDXDevZip) Bin\*\*.* License.txt ReleaseNotes.md Readme.md'/>
129-
</Target>
130-
131-
<Target Name="ZipRelease">
132-
<Delete Files="$(SharpDXReleaseZip)"/>
133-
<Exec WorkingDirectory="$(SharpDXRepo)" Command='$(SharpDXRepo)\External\7-Zip\7z.exe a -sfx7z.sfx -xr!External -xr!*.check -xr!*.pdb -xr!*.lib -xr!*.pri -xr!*.exp $(SharpDXReleaseZip) Bin\*\*.* License.txt ReleaseNotes.md Readme.md'/>
134-
</Target>
135-
136131
</Project>

0 commit comments

Comments
 (0)