|
1 | | -<?xml version="1.0" encoding="utf-8"?> |
| 1 | +<?xml version="1.0" encoding="utf-8"?> |
2 | 2 | <!-- |
3 | 3 |
|
4 | 4 | Licensed to the Apache Software Foundation (ASF) under one |
|
19 | 19 | under the License. |
20 | 20 |
|
21 | 21 | --> |
22 | | -<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
23 | | - <PropertyGroup> |
24 | | - <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir> |
25 | | - |
26 | | - <!-- Enable the restore command to run before builds --> |
27 | | - <RestorePackages Condition=" '$(RestorePackages)' == '' ">false</RestorePackages> |
28 | | - |
29 | | - <!-- Property that enables building a package from a project --> |
30 | | - <BuildPackage Condition=" '$(BuildPackage)' == '' ">false</BuildPackage> |
31 | | - |
32 | | - <!-- Determines if package restore consent is required to restore packages --> |
33 | | - <RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">true</RequireRestoreConsent> |
34 | | - |
35 | | - <!-- Download NuGet.exe if it does not already exist --> |
36 | | - <DownloadNuGetExe Condition=" '$(DownloadNuGetExe)' == '' ">false</DownloadNuGetExe> |
37 | | - </PropertyGroup> |
38 | | - <ItemGroup Condition=" '$(PackageSources)' == '' "> |
39 | | - <!-- Package sources used to restore packages. By default, registered sources under %APPDATA%\NuGet\NuGet.Config will be used --> |
40 | | - <!-- The official NuGet package source (https://www.nuget.org/api/v2/) will be excluded if package sources are specified and it does not appear in the list --> |
41 | | - <!-- |
42 | | - <PackageSource Include="https://www.nuget.org/api/v2/" /> |
43 | | - <PackageSource Include="https://my-nuget-source/nuget/" /> |
44 | | - --> |
45 | | - </ItemGroup> |
46 | | - |
| 22 | +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
| 23 | + <PropertyGroup> |
| 24 | + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir> |
| 25 | + |
| 26 | + <!-- Enable the restore command to run before builds --> |
| 27 | + <RestorePackages Condition=" '$(RestorePackages)' == '' ">false</RestorePackages> |
| 28 | + |
| 29 | + <!-- Property that enables building a package from a project --> |
| 30 | + <BuildPackage Condition=" '$(BuildPackage)' == '' ">false</BuildPackage> |
| 31 | + |
| 32 | + <!-- Determines if package restore consent is required to restore packages --> |
| 33 | + <RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">true</RequireRestoreConsent> |
| 34 | + |
| 35 | + <!-- Download NuGet.exe if it does not already exist --> |
| 36 | + <DownloadNuGetExe Condition=" '$(DownloadNuGetExe)' == '' ">false</DownloadNuGetExe> |
| 37 | + </PropertyGroup> |
| 38 | + <ItemGroup Condition=" '$(PackageSources)' == '' "> |
| 39 | + <!-- Package sources used to restore packages. By default, registered sources under %APPDATA%\NuGet\NuGet.Config will be used --> |
| 40 | + <!-- The official NuGet package source (https://www.nuget.org/api/v2/) will be excluded if package sources are specified and it does not appear in the list --> |
| 41 | + <!-- |
| 42 | + <PackageSource Include="https://www.nuget.org/api/v2/" /> |
| 43 | + <PackageSource Include="https://my-nuget-source/nuget/" /> |
| 44 | + --> |
| 45 | + </ItemGroup> |
| 46 | + |
47 | 47 | <PropertyGroup Condition=" '$(OS)' == 'Windows_NT' And '$(BuildWithMono)' != 'true'"> |
48 | | - <!-- Windows specific commands --> |
49 | | - <NuGetToolsPath>$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath> |
50 | | - <PackagesConfig>$([System.IO.Path]::Combine($(ProjectDir), "packages.config"))</PackagesConfig> |
51 | | - </PropertyGroup> |
| 48 | + <!-- Windows specific commands --> |
| 49 | + <NuGetToolsPath>$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath> |
| 50 | + <PackagesConfig>$([System.IO.Path]::Combine($(ProjectDir), "packages.config"))</PackagesConfig> |
| 51 | + </PropertyGroup> |
52 | 52 |
|
53 | 53 | <PropertyGroup Condition=" '$(OS)' != 'Windows_NT' Or '$(BuildWithMono)' == 'true'"> |
54 | | - <!-- We need to launch nuget.exe with the mono command if we're not on windows --> |
55 | | - <NuGetToolsPath>$(SolutionDir).nuget</NuGetToolsPath> |
| 54 | + <!-- We need to launch nuget.exe with the mono command if we're not on windows --> |
| 55 | + <NuGetToolsPath>$(SolutionDir).nuget</NuGetToolsPath> |
56 | 56 | <PackagesConfig>$(ProjectDir)packages.config</PackagesConfig> |
57 | | - </PropertyGroup> |
| 57 | + </PropertyGroup> |
58 | 58 |
|
59 | | - <PropertyGroup> |
60 | | - <!-- NuGet command --> |
61 | | - <NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(NuGetToolsPath)\NuGet.exe</NuGetExePath> |
62 | | - <PackageSources Condition=" $(PackageSources) == '' ">@(PackageSource)</PackageSources> |
| 59 | + <PropertyGroup> |
| 60 | + <!-- NuGet command --> |
| 61 | + <NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(NuGetToolsPath)\NuGet.exe</NuGetExePath> |
| 62 | + <PackageSources Condition=" $(PackageSources) == '' ">@(PackageSource)</PackageSources> |
63 | 63 |
|
64 | 64 | <NuGetCommand Condition=" '$(OS)' == 'Windows_NT' And '$(BuildWithMono)' != 'true' ">"$(NuGetExePath)"</NuGetCommand> |
65 | 65 | <NuGetCommand Condition=" '$(OS)' != 'Windows_NT' Or '$(BuildWithMono)' == 'true' ">mono --runtime=v4.0.30319 $(NuGetExePath)</NuGetCommand> |
66 | | - |
67 | | - <PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir> |
68 | 66 |
|
69 | | - <RequireConsentSwitch Condition=" $(RequireRestoreConsent) == 'true' ">-RequireConsent</RequireConsentSwitch> |
70 | | - <NonInteractiveSwitch Condition=" '$(VisualStudioVersion)' != '' AND '$(OS)' == 'Windows_NT' ">-NonInteractive</NonInteractiveSwitch> |
71 | | - |
72 | | - <!-- Commands --> |
| 67 | + <PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir> |
| 68 | + |
| 69 | + <RequireConsentSwitch Condition=" $(RequireRestoreConsent) == 'true' ">-RequireConsent</RequireConsentSwitch> |
| 70 | + <NonInteractiveSwitch Condition=" '$(VisualStudioVersion)' != '' AND '$(OS)' == 'Windows_NT' ">-NonInteractive</NonInteractiveSwitch> |
| 71 | + |
| 72 | + <!-- Commands --> |
73 | 73 | <RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir "$(SolutionDir)\" </RestoreCommand> |
74 | 74 | <BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -Properties Configuration=$(Configuration) $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols</BuildCommand> |
75 | | - |
76 | | - <!-- We need to ensure packages are restored prior to assembly resolve --> |
77 | | - <BuildDependsOn Condition="$(RestorePackages) == 'true'"> |
78 | | - RestorePackages; |
79 | | - $(BuildDependsOn); |
80 | | - </BuildDependsOn> |
81 | | - |
82 | | - <!-- Make the build depend on restore packages --> |
83 | | - <BuildDependsOn Condition="$(BuildPackage) == 'true'"> |
84 | | - $(BuildDependsOn); |
85 | | - BuildPackage; |
86 | | - </BuildDependsOn> |
87 | | - </PropertyGroup> |
88 | | - |
89 | | - <Target Name="CheckPrerequisites"> |
90 | | - <!-- Raise an error if we're unable to locate nuget.exe --> |
91 | | - <Error Condition="'$(DownloadNuGetExe)' != 'true' AND !Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" /> |
92 | | - <!-- |
93 | | - Take advantage of MsBuild's build dependency tracking to make sure that we only ever download nuget.exe once. |
94 | | - This effectively acts as a lock that makes sure that the download operation will only happen once and all |
95 | | - parallel builds will have to wait for it to complete. |
96 | | - --> |
97 | | - <MsBuild Targets="_DownloadNuGet" Projects="$(MSBuildThisFileFullPath)" Properties="Configuration=NOT_IMPORTANT;DownloadNuGetExe=$(DownloadNuGetExe)" /> |
98 | | - </Target> |
99 | | - |
100 | | - <Target Name="_DownloadNuGet"> |
101 | | - <DownloadNuGet OutputFilename="$(NuGetExePath)" Condition=" '$(DownloadNuGetExe)' == 'true' AND !Exists('$(NuGetExePath)')" /> |
102 | | - </Target> |
103 | | - |
104 | | - <Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites"> |
105 | | - <Exec Command="$(RestoreCommand)" |
| 75 | + |
| 76 | + <!-- We need to ensure packages are restored prior to assembly resolve --> |
| 77 | + <BuildDependsOn Condition="$(RestorePackages) == 'true'"> |
| 78 | + RestorePackages; |
| 79 | + $(BuildDependsOn); |
| 80 | + </BuildDependsOn> |
| 81 | + |
| 82 | + <!-- Make the build depend on restore packages --> |
| 83 | + <BuildDependsOn Condition="$(BuildPackage) == 'true'"> |
| 84 | + $(BuildDependsOn); |
| 85 | + BuildPackage; |
| 86 | + </BuildDependsOn> |
| 87 | + </PropertyGroup> |
| 88 | + |
| 89 | + <Target Name="CheckPrerequisites"> |
| 90 | + <!-- Raise an error if we're unable to locate nuget.exe --> |
| 91 | + <Error Condition="'$(DownloadNuGetExe)' != 'true' AND !Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" /> |
| 92 | + <!-- |
| 93 | + Take advantage of MsBuild's build dependency tracking to make sure that we only ever download nuget.exe once. |
| 94 | + This effectively acts as a lock that makes sure that the download operation will only happen once and all |
| 95 | + parallel builds will have to wait for it to complete. |
| 96 | + --> |
| 97 | + <MsBuild Targets="_DownloadNuGet" Projects="$(MSBuildThisFileFullPath)" Properties="Configuration=NOT_IMPORTANT;DownloadNuGetExe=$(DownloadNuGetExe)" /> |
| 98 | + </Target> |
| 99 | + |
| 100 | + <Target Name="_DownloadNuGet"> |
| 101 | + <DownloadNuGet OutputFilename="$(NuGetExePath)" Condition=" '$(DownloadNuGetExe)' == 'true' AND !Exists('$(NuGetExePath)')" /> |
| 102 | + </Target> |
| 103 | + |
| 104 | + <Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites"> |
| 105 | + <Exec Command="$(RestoreCommand)" |
106 | 106 | Condition="( '$(OS)' != 'Windows_NT' Or '$(BuildWithMono)' == 'true' ) And Exists('$(PackagesConfig)')" /> |
107 | 107 |
|
108 | | - <Exec Command="$(RestoreCommand)" |
109 | | - LogStandardErrorAsError="true" |
| 108 | + <Exec Command="$(RestoreCommand)" |
| 109 | + LogStandardErrorAsError="true" |
110 | 110 | Condition="'$(OS)' == 'Windows_NT' And '$(BuildWithMono)' != 'true' And Exists('$(PackagesConfig)')" /> |
111 | | - </Target> |
112 | | - |
113 | | - <Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites"> |
| 111 | + </Target> |
| 112 | + |
| 113 | + <Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites"> |
114 | 114 | <Exec Command="$(BuildCommand)" |
115 | 115 | Condition=" '$(OS)' != 'Windows_NT' Or '$(BuildWithMono)' " /> |
116 | 116 |
|
117 | | - <Exec Command="$(BuildCommand)" |
118 | | - LogStandardErrorAsError="true" |
| 117 | + <Exec Command="$(BuildCommand)" |
| 118 | + LogStandardErrorAsError="true" |
119 | 119 | Condition=" '$(OS)' == 'Windows_NT' And '$(BuildWithMono)' != 'true' " /> |
120 | | - </Target> |
121 | | - |
122 | | - <UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll"> |
123 | | - <ParameterGroup> |
124 | | - <OutputFilename ParameterType="System.String" Required="true" /> |
125 | | - </ParameterGroup> |
126 | | - <Task> |
127 | | - <Reference Include="System.Core" /> |
128 | | - <Using Namespace="System" /> |
129 | | - <Using Namespace="System.IO" /> |
130 | | - <Using Namespace="System.Net" /> |
131 | | - <Using Namespace="Microsoft.Build.Framework" /> |
132 | | - <Using Namespace="Microsoft.Build.Utilities" /> |
133 | | - <Code Type="Fragment" Language="cs"> |
134 | | - <![CDATA[ |
135 | | - try { |
136 | | - OutputFilename = Path.GetFullPath(OutputFilename); |
137 | | -
|
138 | | - Log.LogMessage("Downloading latest version of NuGet.exe..."); |
139 | | - WebClient webClient = new WebClient(); |
140 | | - webClient.DownloadFile("https://www.nuget.org/nuget.exe", OutputFilename); |
141 | | -
|
142 | | - return true; |
143 | | - } |
144 | | - catch (Exception ex) { |
145 | | - Log.LogErrorFromException(ex); |
146 | | - return false; |
147 | | - } |
148 | | - ]]> |
149 | | - </Code> |
150 | | - </Task> |
151 | | - </UsingTask> |
| 120 | + </Target> |
| 121 | + |
| 122 | + <UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll"> |
| 123 | + <ParameterGroup> |
| 124 | + <OutputFilename ParameterType="System.String" Required="true" /> |
| 125 | + </ParameterGroup> |
| 126 | + <Task> |
| 127 | + <Reference Include="System.Core" /> |
| 128 | + <Using Namespace="System" /> |
| 129 | + <Using Namespace="System.IO" /> |
| 130 | + <Using Namespace="System.Net" /> |
| 131 | + <Using Namespace="Microsoft.Build.Framework" /> |
| 132 | + <Using Namespace="Microsoft.Build.Utilities" /> |
| 133 | + <Code Type="Fragment" Language="cs"> |
| 134 | + <![CDATA[ |
| 135 | + try { |
| 136 | + OutputFilename = Path.GetFullPath(OutputFilename); |
| 137 | +
|
| 138 | + Log.LogMessage("Downloading latest version of NuGet.exe..."); |
| 139 | + WebClient webClient = new WebClient(); |
| 140 | + webClient.DownloadFile("https://www.nuget.org/nuget.exe", OutputFilename); |
| 141 | +
|
| 142 | + return true; |
| 143 | + } |
| 144 | + catch (Exception ex) { |
| 145 | + Log.LogErrorFromException(ex); |
| 146 | + return false; |
| 147 | + } |
| 148 | + ]]> |
| 149 | + </Code> |
| 150 | + </Task> |
| 151 | + </UsingTask> |
152 | 152 | </Project> |
0 commit comments