You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
NuGetGallery/build.msbuild

67 lines
3.2 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v$(MSBuildToolsVersion).dll">
<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...");
WebClient webClient = new WebClient();
webClient.DownloadFile("https://nuget.org/nuget.exe", OutputFilename);
return true;
}
catch (Exception ex) {
Log.LogErrorFromException(ex);
return false;
}
]]>
</Code>
</Task>
</UsingTask>
<Target Name="RestorePackages">
<ItemGroup>
<!-- Package sources used to restore packages. By default will used the registered sources under %APPDATA%\NuGet\NuGet.Config -->
<PackageSource Include="https://www.nuget.org/api/v2" />
<PackageSource Include="https://www.myget.org/F/nugetbuild/" />
</ItemGroup>
<PropertyGroup>
<NuGetExeDir>$(MSBuildThisFileDirectory)\.nuget</NuGetExeDir>
<NuGetExePath>$(NuGetExeDir)\nuget.exe</NuGetExePath>
<RestoreCommand>$(NuGetExePath) restore -Source "@(PackageSource)" "@(SolutionFile)" -NonInteractive</RestoreCommand>
</PropertyGroup>
<MakeDir Directories="$(NuGetExeDir)" Condition="!Exists('$(NuGetExeDir)')" />
<Message Text="Restoring packages ... " Importance="high" />
<DownloadNuGet OutputFilename="$(NuGetExePath)" Condition=" !Exists('$(NuGetExePath)')" />
<Exec Command="$(RestoreCommand)" LogStandardErrorAsError="true" />
</Target>
<Target Name="CheckForMultipleSolutions">
<Error Text="Multiple solutions exist in $(RepositoryRoot)!" Condition="'@(SolutionFile->Count())' &gt; 1" />
</Target>
<Target Name="CoreBuild">
<!-- Find the version we're looking for -->
<Exec Command="dir packages\NuGet.Services.Build* /O:-N /B" StandardOutputImportance="low" ConsoleToMSBuild="true" EchoOff="true">
<Output TaskParameter="ConsoleOutput" PropertyName="Versions" />
</Exec>
<PropertyGroup>
<_NuGetServicesBuildVersion>$(Versions.Split(";")[0])</_NuGetServicesBuildVersion>
</PropertyGroup>
<MSBuild Projects="$(MSBuildThisFileDirectory)packages\$(_NuGetServicesBuildVersion)\tools\NuGet.Services.FullBuild.msbuild" />
</Target>
<Target Name="Build" DependsOnTargets="CheckForMultipleSolutions;RestorePackages;CoreBuild" />
</Project>