forked from dotnet/msbuild
-
Notifications
You must be signed in to change notification settings - Fork 3
/
dir.targets
88 lines (74 loc) · 3.83 KB
/
dir.targets
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?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" />
<Reference Include="System.IO" />
<Code Type="Fragment" Language="cs">
<![CDATA[
var directory = System.IO.Path.GetDirectoryName(FileName);
Directory.CreateDirectory(directory);
var tempFile = Path.Combine(directory, Path.GetRandomFileName());
var client = new System.Net.WebClient();
client.Proxy = System.Net.WebRequest.DefaultWebProxy;
client.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
client.DownloadFile(Address, tempFile);
try
{
if (!File.Exists(FileName))
File.Move(tempFile, FileName);
}
finally
{
if (File.Exists(tempFile))
File.Delete(tempFile);
}
]]>
</Code>
</Task>
</UsingTask>
<!--
Needed to avoid the InitialTargets 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="_CopyCompilers" AfterTargets="_RestoreBuildTools" Condition="'$(UseRoslynCompilers)' == 'true'">
<ItemGroup>
<BuildFiles Include="$(PackagesDir)Microsoft.Net.ToolsetCompilers*\build\*" />
<ToolsFiles Include="$(PackagesDir)Microsoft.Net.ToolsetCompilers*\tools\*" />
</ItemGroup>
<Copy
SourceFiles="@(BuildFiles);@(ToolsFiles)"
DestinationFolder="$(OutputPath)tools"
SkipUnchangedFiles="true"
/>
<Exec Condition="'$(OS)' != 'Windows_NT'" Command="find '$(OutputPath)tools' -name "*.exe" -exec chmod "+x" '{}' ';'" />
</Target>
<Target Name="_RestoreBuildTools"
Inputs="$(MSBuildThisFileFullPath);$(MSBuildThisFileDirectory)dir.props"
Outputs="$(ToolsDir)Microsoft.DotNet.Build.Tasks.dll;$(NugetToolPath)">
<!-- Download latest nuget.exe -->
<DownloadFile FileName="$(NuGetToolPath)"
Address="http://nuget.org/nuget.exe"
Condition="!Exists('$(NuGetToolPath)')" />
<!-- Restore build tools -->
<Exec Command="$(NugetRestoreCommand) "$(SourceDir).nuget\packages.config"" 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>
<!-- Get access to the xunit task from the globally-installed location -->
<Import Project="packages\xunit.runner.msbuild.2.1.0-beta4-build3109\build\portable-net45+netcore45+wp8+wpa81\xunit.runner.msbuild.props" Condition="Exists('packages\xunit.runner.msbuild.2.1.0-beta4-build3109\build\portable-net45+netcore45+wp8+wpa81\xunit.runner.msbuild.props')" />
<Target Name="Test"
DependsOnTargets="Build"
Condition="'$(IsTestProject)' == 'true'">
<xunit Assemblies="@(MainAssembly)"
ShadowCopy="false" />
</Target>
<Target Name="BuildAndTest"
DependsOnTargets="Build;Test" />
</Project>