-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathpackaging.targets
58 lines (58 loc) · 3.29 KB
/
packaging.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
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT'">
<!-- Windows specific commands -->
<NuGetToolsPath>$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(OS)' != 'Windows_NT'">
<!-- We need to launch nuget.exe with the mono command if we're not on windows -->
<NuGetToolsPath>$(SolutionDir).nuget</NuGetToolsPath>
</PropertyGroup>
<!--
NuGet default properties
Can be overwritten with MSBuild parameters (f.e. "... /p:BuildPackageCustom=false ...")
-->
<PropertyGroup>
<!-- use custom nuget package build -->
<BuildPackageCustom Condition="'$(BuildPackageCustom)' == ''">true</BuildPackageCustom>
<!-- publish nuget packages -->
<PublishPackage Condition="'$(PublishPackage)' == ''">true</PublishPackage>
<!-- push to local nuget repository -->
<NugetRepository Condition="'$(NugetRepository)' == ''">C:\nuget_local</NugetRepository>
<PrereleaseVersion Condition="'$(PrereleaseVersion)' == ''"></PrereleaseVersion>
</PropertyGroup>
<!-- get package version from versioning.target, if any -->
<Choose>
<When Condition="'$(PrereleaseVersion)' != ''">
<PropertyGroup>
<NugetPackageVersion>$(PackageVersion)-$(PrereleaseVersion)$([System.String]::Format('{0:000}', $([MSBuild]::Add($(BuildNumber), 0))))</NugetPackageVersion>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<NugetPackageVersion>$(PackageVersion)</NugetPackageVersion>
</PropertyGroup>
</Otherwise>
</Choose>
<PropertyGroup>
<BuildDependsOn>
$(BuildDependsOn);
BuildPackageCustom;
PublishPackage;
</BuildDependsOn>
<NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(NuGetToolsPath)\NuGet.exe</NuGetExePath>
<NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand>
<NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 $(NuGetExePath)</NuGetCommand>
<_NugetApiKey Condition="'$(NugetApiKey)' != ''"> -ApiKey "$(NugetApiKey)"</_NugetApiKey>
<PackageOutputDir>$([System.IO.Path]::GetDirectoryName('$(ProjectDir)$(IntermediateOutputPath)'))</PackageOutputDir>
<PackageSpec>$(ProjectPath.Replace('.csproj', '.nuspec'))</PackageSpec>
<PackageOutput>$(ProjectName.Replace('.csproj', '')).*$(NugetPackageVersion).nupkg</PackageOutput>
<BuildCommandSolution Condition="'$(NugetPackageVersion)' != ''">$(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -Symbols -SymbolPackageFormat snupkg -Properties "DependentVersion=$(NugetPackageVersion)" -Version "$(NugetPackageVersion)"</BuildCommandSolution>
<PublishCommand>$(NuGetCommand) push "$(PackageOutputDir)\$(PackageOutput)" $(_NugetApiKey) -source "$(NugetRepository)"</PublishCommand>
</PropertyGroup>
<Target Name="PublishPackage" Condition="'$(PublishPackage)' == 'true'">
<Exec Command="$(PublishCommand)" LogStandardErrorAsError="true" />
</Target>
<Target Name="BuildPackageCustom" Condition="$(BuildPackageCustom) == 'true'">
<Exec Command="$(BuildCommandSolution)" LogStandardErrorAsError="true" />
</Target>
</Project>