22<Project ToolsVersion =" 4.0" xmlns =" http://schemas.microsoft.com/developer/msbuild/2003" >
33 <PropertyGroup >
44 <SolutionDir Condition =" $(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'" >$(MSBuildProjectDirectory)\..\</SolutionDir >
5-
5+
66 <!-- Enable the restore command to run before builds -->
77 <RestorePackages Condition =" '$(RestorePackages)' == '' " >false</RestorePackages >
88
1111
1212 <!-- Determines if package restore consent is required to restore packages -->
1313 <RequireRestoreConsent Condition =" '$(RequireRestoreConsent)' != 'false' " >true</RequireRestoreConsent >
14-
14+
1515 <!-- Download NuGet.exe if it does not already exist -->
1616 <DownloadNuGetExe Condition =" '$(DownloadNuGetExe)' == '' " >false</DownloadNuGetExe >
1717 </PropertyGroup >
18-
18+
1919 <ItemGroup Condition =" '$(PackageSources)' == '' " >
2020 <!-- Package sources used to restore packages. By default, registered sources under %APPDATA%\NuGet\NuGet.Config will be used -->
21- <!-- The official NuGet package source (https://nuget.org/api/v2/) will be excluded if package sources are specified and it does not appear in the list -->
21+ <!-- 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 -->
2222 <!--
23- <PackageSource Include="https://nuget.org/api/v2/" />
23+ <PackageSource Include="https://www. nuget.org/api/v2/" />
2424 <PackageSource Include="https://my-nuget-source/nuget/" />
2525 -->
2626 </ItemGroup >
2727
2828 <PropertyGroup Condition =" '$(OS)' == 'Windows_NT'" >
2929 <!-- Windows specific commands -->
3030 <NuGetToolsPath >$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath >
31- <PackagesConfig >$([System.IO.Path]::Combine($(ProjectDir), "packages.config"))</PackagesConfig >
3231 </PropertyGroup >
33-
32+
3433 <PropertyGroup Condition =" '$(OS)' != 'Windows_NT'" >
3534 <!-- We need to launch nuget.exe with the mono command if we're not on windows -->
3635 <NuGetToolsPath >$(SolutionDir).nuget</NuGetToolsPath >
37- <PackagesConfig >packages.config</PackagesConfig >
36+ </PropertyGroup >
37+
38+ <PropertyGroup >
39+ <PackagesProjectConfig Condition =" '$(OS)' == 'Windows_NT'" >$(MSBuildProjectDirectory)\packages.$(MSBuildProjectName.Replace(' ', '_')).config</PackagesProjectConfig >
40+ <PackagesProjectConfig Condition =" '$(OS)' != 'Windows_NT'" >$(MSBuildProjectDirectory)\packages.$(MSBuildProjectName).config</PackagesProjectConfig >
41+ </PropertyGroup >
42+
43+ <PropertyGroup >
44+ <PackagesConfig Condition =" Exists('$(MSBuildProjectDirectory)\packages.config')" >$(MSBuildProjectDirectory)\packages.config</PackagesConfig >
45+ <PackagesConfig Condition =" Exists('$(PackagesProjectConfig)')" >$(PackagesProjectConfig)</PackagesConfig >
3846 </PropertyGroup >
3947
4048 <PropertyGroup >
4149 <!-- NuGet command -->
4250 <NuGetExePath Condition =" '$(NuGetExePath)' == '' " >$(NuGetToolsPath)\NuGet.exe</NuGetExePath >
4351 <PackageSources Condition =" $(PackageSources) == '' " >@(PackageSource)</PackageSources >
44-
52+
4553 <NuGetCommand Condition =" '$(OS)' == 'Windows_NT'" >"$(NuGetExePath)"</NuGetCommand >
46- <NuGetCommand Condition =" '$(OS)' != 'Windows_NT' " >mono --runtime=v4.0.30319 $(NuGetExePath)</NuGetCommand >
54+ <NuGetCommand Condition =" '$(OS)' != 'Windows_NT' " >mono --runtime=v4.0.30319 " $(NuGetExePath)" </NuGetCommand >
4755
4856 <PackageOutputDir Condition =" $(PackageOutputDir) == ''" >$(TargetDir.Trim('\\'))</PackageOutputDir >
49-
57+
5058 <RequireConsentSwitch Condition =" $(RequireRestoreConsent) == 'true' " >-RequireConsent</RequireConsentSwitch >
5159 <NonInteractiveSwitch Condition =" '$(VisualStudioVersion)' != '' AND '$(OS)' == 'Windows_NT' " >-NonInteractive</NonInteractiveSwitch >
52-
60+
61+ <PaddedSolutionDir Condition =" '$(OS)' == 'Windows_NT'" >"$(SolutionDir) "</PaddedSolutionDir >
62+ <PaddedSolutionDir Condition =" '$(OS)' != 'Windows_NT' " >"$(SolutionDir)"</PaddedSolutionDir >
63+
5364 <!-- Commands -->
54- <RestoreCommand >$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir "$(SolutionDir) " </RestoreCommand >
55- <BuildCommand >$(NuGetCommand) pack "$(ProjectPath)" -Properties Configuration=$(Configuration) $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols</BuildCommand >
65+ <RestoreCommand >$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir) </RestoreCommand >
66+ <BuildCommand >$(NuGetCommand) pack "$(ProjectPath)" -Properties " Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols</BuildCommand >
5667
5768 <!-- We need to ensure packages are restored prior to assembly resolve -->
5869 <BuildDependsOn Condition =" $(RestorePackages) == 'true'" >
8293 <DownloadNuGet OutputFilename =" $(NuGetExePath)" Condition =" '$(DownloadNuGetExe)' == 'true' AND !Exists('$(NuGetExePath)')" />
8394 </Target >
8495
85- <Target Name =" RestorePackages" DependsOnTargets =" CheckPrerequisites" >
96+ <Target Name =" RestorePackages" DependsOnTargets =" CheckPrerequisites" >
8697 <Exec Command =" $(RestoreCommand)"
8798 Condition =" '$(OS)' != 'Windows_NT' And Exists('$(PackagesConfig)')" />
88-
99+
89100 <Exec Command =" $(RestoreCommand)"
90101 LogStandardErrorAsError =" true"
91102 Condition =" '$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" />
92103 </Target >
93104
94105 <Target Name =" BuildPackage" DependsOnTargets =" CheckPrerequisites" >
95- <Exec Command =" $(BuildCommand)"
106+ <Exec Command =" $(BuildCommand)"
96107 Condition =" '$(OS)' != 'Windows_NT' " />
97-
108+
98109 <Exec Command =" $(BuildCommand)"
99110 LogStandardErrorAsError =" true"
100111 Condition =" '$(OS)' == 'Windows_NT' " />
101112 </Target >
102-
113+
103114 <UsingTask TaskName =" DownloadNuGet" TaskFactory =" CodeTaskFactory" AssemblyFile =" $(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll" >
104115 <ParameterGroup >
105116 <OutputFilename ParameterType =" System.String" Required =" true" />
118129
119130 Log.LogMessage("Downloading latest version of NuGet.exe...");
120131 WebClient webClient = new WebClient();
121- webClient.DownloadFile("https://nuget.org/nuget.exe", OutputFilename);
132+ webClient.DownloadFile("https://www. nuget.org/nuget.exe", OutputFilename);
122133
123134 return true;
124135 }
130141 </Code >
131142 </Task >
132143 </UsingTask >
133- </Project >
144+ </Project >
0 commit comments