targets/DeployDependencies.proj (155 lines of code) (raw):
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="DeployDependencies" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\dir.props" />
<!-- Copy Roslyn Compiler tools to the output path (so we have csc.exe, etc) -->
<!-- On .NET Core, we deploy compiler tools by copying the package assets
in RestoreRuntimePackages, but the full-framework Roslyn packages don't
deliver everything as assets, so this copies them from the tools/ folder. -->
<Target Name="CopyCompilerTools"
Condition="'$(NetCoreBuild)' != 'true'">
<ItemGroup>
<CompilerToolsFiles Include="$(CompilerToolsDir)\*.*" />
</ItemGroup>
<Copy SourceFiles="@(CompilerToolsFiles)"
DestinationFolder="$(DeploymentDir)\Roslyn"
SkipUnchangedFiles="true" />
<Copy SourceFiles="@(CompilerToolsFiles)"
DestinationFolder="$(TestDeploymentDir)\Roslyn"
SkipUnchangedFiles="true" />
</Target>
<!-- Copy content of BuildTools package to deployment folders -->
<Target Name="CopyBuildTools">
<PropertyGroup>
<BuildToolsVersionFile>$(RepoRoot)BuildToolsVersion.txt</BuildToolsVersionFile>
</PropertyGroup>
<ReadLinesFromFile File="$(BuildToolsVersionFile)">
<Output TaskParameter="Lines" ItemName="BuildToolsVersion" />
</ReadLinesFromFile>
<PropertyGroup>
<BuildToolsVersion>@(BuildToolsVersion)</BuildToolsVersion>
</PropertyGroup>
<ItemGroup>
<BuildToolsFiles Include="$(ToolPackagesDir)Microsoft.DotNet.BuildTools\$(BuildToolsVersion)\lib\*.*" />
</ItemGroup>
<Copy SourceFiles="@(BuildToolsFiles)"
DestinationFolder="$(DeploymentDir)"
SkipUnchangedFiles="true"
/>
<Copy SourceFiles="@(BuildToolsFiles)"
DestinationFolder="$(TestDeploymentDir)"
SkipUnchangedFiles="true"
/>
</Target>
<Target Name="CopyPackageContent">
<ItemGroup>
<!-- We want the list of files *after* restore, which happens
early in build, so this item can't be defined outside of a
target. -->
<PackagesFoldersInPackagesDir Include="$(PackagesDir)\Microsoft.Portable.Targets\0.1.1-dev\" />
<!-- For each package, get its content files. -->
<ContentFilesFromPackage Include="%(PackagesFoldersInPackagesDir.Identity)contentFiles\any\any\**\*.*" />
</ItemGroup>
<!-- Copy the dependencies to both the deployment and the test directories -->
<ItemGroup>
<DeploymentDestination Include="@(ContentFilesFromPackage->'$(DeploymentDir)\%(RecursiveDir)%(Filename)%(Extension)')" />
<TestDeploymentDestination Include="@(ContentFilesFromPackage->'$(TestDeploymentDir)\%(RecursiveDir)%(Filename)%(Extension)')" />
</ItemGroup>
<!-- Copy the package contents to both the deployment and test deployment directory -->
<Copy SourceFiles="@(ContentFilesFromPackage)"
DestinationFiles="@(DeploymentDestination)"
SkipUnchangedFiles="true"
/>
<Copy SourceFiles="@(ContentFilesFromPackage)"
DestinationFiles="@(TestDeploymentDestination)"
SkipUnchangedFiles="true"
/>
</Target>
<UsingTask TaskName="PrereleaseResolveNuGetPackageAssets" AssemblyFile="$(ToolsDir)net45/Microsoft.DotNet.Build.Tasks.dll"/>
<PropertyGroup>
<!--At build time, we target netstandard to be runnable on many runtimes.
To get a set of runnable bits, we need to deploy a specific one. On the xplat branch we are testing the .net core runtime platform, so we target netcoreapp -->
<NuGetTargetMoniker Condition="'$(NetCoreBuild)' == 'true'">.NETCoreApp,Version=v1.0</NuGetTargetMoniker>
<NuGetRuntimeIdentifier>$(RuntimeSystem)-$(RuntimeArchitecture)</NuGetRuntimeIdentifier>
</PropertyGroup>
<ItemGroup>
<RuntimeProjectJson Include="$(MSBuildThisFileDirectory)runtimeDependencies\project.json">
<LockFile>$(MSBuildThisFileDirectory)runtimeDependencies\project.lock.json</LockFile>
<DestinationFolder>$(DeploymentDir)</DestinationFolder>
<TestDeploymentDir>$(TestDeploymentDir)</TestDeploymentDir>
</RuntimeProjectJson>
<RuntimeProjectJson Include="$(MSBuildThisFileDirectory)roslyn\project.json">
<LockFile>$(MSBuildThisFileDirectory)roslyn\project.lock.json</LockFile>
<DestinationFolder>$(DeploymentDir)\Roslyn</DestinationFolder>
<TestDeploymentDir>$(TestDeploymentDir)\Roslyn</TestDeploymentDir>
</RuntimeProjectJson>
</ItemGroup>
<Target Name="RestoreRuntimePackages"
Inputs="$(DnuToolPath);@(RuntimeProjectJson)"
Outputs="@(RuntimeProjectJson->'%(LockFile)')">
<Exec Command="$(DnuRestoreCommand) "%(RuntimeProjectJson.FullPath)"" StandardOutputImportance="Low" />
<!-- It appears that NuGet doesn't re-write the project.lock.json file if the contents would be the same. This can mess up incremental builds
if you make a non-significant change to project.json. To avoid that, update the timestamp of the lock file here. -->
<Touch Files="@(RuntimeProjectJson->'%(LockFile)')" />
</Target>
<Target Name="DeployRuntime"
DependsOnTargets="RestoreRuntimePackages"
Outputs="%(RuntimeProjectJson.LockFile).IntentionallyDoesNotExistSoThisAlwaysRuns">
<PrereleaseResolveNuGetPackageAssets AllowFallbackOnTargetSelection="true"
IncludeFrameworkReferences="false"
NuGetPackagesDirectory="$(PackagesDir)"
RuntimeIdentifier="$(NuGetRuntimeIdentifier)"
ProjectLanguage="C#"
ProjectLockFile="@(RuntimeProjectJson->'%(LockFile)')"
TargetMonikers="$(NuGetTargetMoniker)">
<Output TaskParameter="ResolvedCopyLocalItems" ItemName="ResolvedRuntimeFiles" />
</PrereleaseResolveNuGetPackageAssets>
<!-- Copy the dependencies to both the deployment and the test directories -->
<Copy SourceFiles="@(ResolvedRuntimeFiles)"
DestinationFolder="@(RuntimeProjectJson->'%(DestinationFolder)')"
SkipUnchangedFiles="true"
/>
<Copy SourceFiles="@(ResolvedRuntimeFiles)"
DestinationFolder="@(RuntimeProjectJson->'%(TestDeploymentDir)')"
SkipUnchangedFiles="true"
/>
<Copy SourceFiles="@(ResolvedRuntimeFiles)"
DestinationFolder="$(OutputPath)"
SkipUnchangedFiles="true"
Condition=" '$(BuildingInsideVisualStudio)' == 'true' "
/>
<Copy SourceFiles="@(ResolvedRuntimeFiles)"
DestinationFolder="$(OutputPath)"
SkipUnchangedFiles="true"
Condition=
"'%(ResolvedRuntimeFiles.NuGetPackageId)' == 'System.Collections.Immutable' or
'%(ResolvedRuntimeFiles.NuGetPackageId)' == 'System.Threading.Tasks.Dataflow' or
'%(ResolvedRuntimeFiles.NuGetPackageId)' == 'System.Runtime.InteropServices.RuntimeInformation'"
/>
</Target>
<!-- The VSIX installer manifest references
System.Collections.Immutable,
System.Threading.Tasks.Dataflow,
System.Runtime.InteropServices.RuntimeInformation
from the Output folder, but they won't be placed there
by default because NuGet references come in as CopyLocal false.
Work around this by manually copying them here.
TODO: this shouldn't be here. After moving to a better binplacing model (like "publish
msbuild.exe to a folder") it should be removed. This whole project file should be removed. :)
-->
<Target Name="CopyDependenciesFromNugetNeededByVsix"
AfterTargets="DeployRuntime">
<Copy SourceFiles="@(ResolvedRuntimeFiles)"
DestinationFolder="$(OutputPath)"
SkipUnchangedFiles="true"
Condition=
"'%(ResolvedRuntimeFiles.NuGetPackageId)' == 'System.Collections.Immutable' or
'%(ResolvedRuntimeFiles.NuGetPackageId)' == 'System.Threading.Tasks.Dataflow' or
'%(ResolvedRuntimeFiles.NuGetPackageId)' == 'System.Runtime.InteropServices.RuntimeInformation'"
/>
</Target>
<Target Name="SetUnixPermissions"
AfterTargets="DeployRuntime"
BeforeTargets="DeployDependencies"
Condition="'$(OsEnvironment)'!='Windows_NT'">
<Exec Command="find "$(DeploymentDir)" -type f -a -name "*" -print0 | xargs -0 -I {} chmod a+xr {}" />
<Exec Command="find "$(TestDeploymentDir)" -type f -a -name "*" -print0 | xargs -0 -I {} chmod a+xr {}" />
</Target>
<Target Name="FixupFilenames"
DependsOnTargets="CopyBuildTools;DeployRuntime"
Condition="'$(OsEnvironment)'!='Windows_NT'">
<!-- Portable targets package has mismatched casing for Microsoft.CSharp.Targets -->
<Copy
SourceFiles="$(DeploymentDir)\Microsoft.CSharp.targets"
DestinationFiles="$(DeploymentDir)\Microsoft.CSharp.Targets"
/>
<Copy
SourceFiles="$(TestDeploymentDir)\Microsoft.CSharp.targets"
DestinationFiles="$(TestDeploymentDir)\Microsoft.CSharp.Targets"
/>
<!-- Csc task looks for dotnet.exe even on non-Windows-->
<Copy
SourceFiles="$(DeploymentDir)\dotnet"
DestinationFiles="$(DeploymentDir)\dotnet.exe"
Condition="'$(MonoBuild)' != 'true'"
/>
<Copy
SourceFiles="$(TestDeploymentDir)\dotnet"
DestinationFiles="$(TestDeploymentDir)\dotnet.exe"
Condition="'$(MonoBuild)' != 'true'"
/>
</Target>
<Target Name="DeployDependencies"
DependsOnTargets="CopyBuildTools;CopyPackageContent;CopyCompilerTools;DeployRuntime;FixupFilenames" />
</Project>