-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Remove NuGet.targets" (I got too excited)
This reverts commit 8cb1a06.
- Loading branch information
Showing
2 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<NuGetToolsPath>$(MSBuildThisFileDirectory)</NuGetToolsPath> | ||
|
||
<!-- NuGet command --> | ||
<NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(NuGetToolsPath)nuget.exe</NuGetExePath> | ||
|
||
<NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand> | ||
<NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono $(NuGetExePath)</NuGetCommand> | ||
<NuGetDownloadUrl>https://dist.nuget.org/win-x86-commandline/latest/nuget.exe</NuGetDownloadUrl> | ||
</PropertyGroup> | ||
|
||
<Target Name="CheckPrerequisites"> | ||
<!-- | ||
Take advantage of MsBuild's build dependency tracking to make sure that we only ever download nuget.exe once. | ||
This effectively acts as a lock that makes sure that the download operation will only happen once and all | ||
parallel builds will have to wait for it to complete. | ||
--> | ||
<MsBuild Targets="_DownloadNuGet" Projects="$(MSBuildThisFileFullPath)" | ||
Properties="Configuration=NOT_IMPORTANT" /> | ||
</Target> | ||
|
||
<Target Name="_DownloadNuGet" Condition="!Exists('$(NuGetExePath)')"> | ||
<DownloadNuGet OutputFilename="$(NuGetExePath)" Condition="'$(OS)' == 'Windows_NT'" /> | ||
<Exec Command="wget $(NuGetDownloadUrl) || curl -O -L $(NuGetDownloadUrl)" | ||
WorkingDirectory="$(NuGetToolsPath)" | ||
Condition="'$(OS)' != 'Windows_NT'" /> | ||
</Target> | ||
|
||
<UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" | ||
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll" | ||
Condition=" '$(OS)' == 'Windows_NT' "> | ||
<ParameterGroup> | ||
<OutputFilename ParameterType="System.String" Required="true" /> | ||
</ParameterGroup> | ||
<Task> | ||
<Reference Include="System.Core" /> | ||
<Using Namespace="System" /> | ||
<Using Namespace="System.IO" /> | ||
<Using Namespace="System.Net" /> | ||
<Using Namespace="Microsoft.Build.Framework" /> | ||
<Using Namespace="Microsoft.Build.Utilities" /> | ||
<Code Type="Fragment" Language="cs"> | ||
<![CDATA[ | ||
try { | ||
OutputFilename = Path.GetFullPath(OutputFilename); | ||
Log.LogMessage("Downloading latest version of nuget.exe..."); | ||
ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12; | ||
WebClient webClient = new WebClient(); | ||
webClient.DownloadFile("$(NuGetDownloadUrl)", OutputFilename); | ||
return true; | ||
} | ||
catch (Exception ex) { | ||
Log.LogErrorFromException(ex); | ||
return false; | ||
} | ||
]]> | ||
</Code> | ||
</Task> | ||
</UsingTask> | ||
</Project> |