Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corefx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWes Haggard <Wes.Haggard@microsoft.com>2015-02-11 12:00:10 +0300
committerWes Haggard <Wes.Haggard@microsoft.com>2015-02-12 03:26:11 +0300
commit894bd6aaf5d2828f82fc01335220824231928e8d (patch)
tree04eec47a059c09356335f19c66966a9551aeb6e0 /dir.targets
parent959c9fb25f03e6576cf43ef6f71b3ef4cb216ddb (diff)
Switch package restore to happen as part of each project build.
This change switches from running package restore all at once in a command line build to doing it for each project one at a time. This allows individual projects to be built successfully from VS and the command line without requring full build of the repo. It also allows the nuget installs to happen in parellel while running a full build as well as makes them respect incremental builds and only restore packages if the packages.config file has changed or the packages folder doesn't exist. One limitation to this model is in some cases when building an individual project from the command line you may hit an error if it is the first to restore the build tools package. The error will tell you retry the build and it will succeed on the second try. This only happens if you build leaf node individual projects from the command line, it will work if you build them in VS or the entire repo from build.cmd/proj first. This is just a limitation of restoring packages in the same msbuild session that is trying to import targets from that restored package.
Diffstat (limited to 'dir.targets')
-rw-r--r--dir.targets48
1 files changed, 48 insertions, 0 deletions
diff --git a/dir.targets b/dir.targets
new file mode 100644
index 0000000000..4edcfc7b03
--- /dev/null
+++ b/dir.targets
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" InitialTargets="_RestoreBuildToolsWrapper" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+
+ <!-- Inline task to bootstrap the build to enable downloading nuget.exe -->
+ <UsingTask TaskName="DownloadFile" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v12.0.dll">
+ <ParameterGroup>
+ <Address ParameterType="System.String" Required="true"/>
+ <FileName ParameterType="System.String" Required="true" />
+ </ParameterGroup>
+ <Task>
+ <Reference Include="System" />
+ <Code Type="Fragment" Language="cs">
+ <![CDATA[
+ var directory = System.IO.Path.GetDirectoryName(FileName);
+ System.IO.Directory.CreateDirectory(directory);
+ var client = new System.Net.WebClient();
+ client.Proxy = System.Net.WebRequest.DefaultWebProxy;
+ client.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
+ client.DownloadFile(Address, FileName);
+ ]]>
+ </Code>
+ </Task>
+ </UsingTask>
+
+ <!--
+ Needed to avoid the IntialTargets from having an Output which ends up getting
+ added to the output references when you have a project to project reference.
+ -->
+ <Target Name="_RestoreBuildToolsWrapper" DependsOnTargets="_RestoreBuildTools" />
+
+ <Target Name="_RestoreBuildTools"
+ Inputs="$(MSBuildThisFileFullPath);$(MSBuildThisFileDirectory)dir.props"
+ Outputs="$(ToolsDir)Microsoft.DotNet.Build.Tasks.dll;$(NugetToolPath)">
+ <Message Importance="High" Text="Restoring build tools..." />
+
+ <!-- Download latest nuget.exe -->
+ <DownloadFile FileName="$(NuGetToolPath)"
+ Address="http://nuget.org/nuget.exe"
+ Condition="!Exists($(NuGetToolPath))" />
+
+ <!-- Restore build tools -->
+ <Exec Command="$(NugetRestoreCommand) &quot;$(SourceDir).nuget\packages.config&quot;" StandardOutputImportance="Low" />
+
+ <Error Condition="'$(ErrorIfBuildToolsRestoredFromIndividualProject)'=='true'"
+ Text="The build tools package was just restored and so we cannot continue the build of an individual project because targets from the build tools package were not able to be imported. Please retry the build the individual project again." />
+ </Target>
+
+</Project> \ No newline at end of file