dotnet-installer/build/Microsoft.DotNet.Cli.Compile.targets
2016-07-06 13:46:54 -07:00

179 lines
No EOL
8.3 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="compile/Microsoft.DotNet.Cli.LzmaArchive.targets" />
<UsingTask TaskName="FixModeFlags" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="ChangeEntryPointLibraryName" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="RemoveAssetFromDepsPackages" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="CleanPublishOutput" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="CrossgenDirectory" AssemblyFile="$(CLIBuildDll)" />
<Target Name="Compile" DependsOnTargets="Prepare;
SetupStage;
CompileStage;
BuildProjectsForNuGetPackages;
GenerateNuGetPackagesArchive" />
<Target Name="SetupStage">
<PropertyGroup>
<SrcDirectory>$(RepoRoot)/src</SrcDirectory>
</PropertyGroup>
<ItemGroup>
<CompileStageInputs Include="$(SrcDirectory)/**/*.cs" Exclude="$(SrcDirectory)/**/obj/**/*.cs" />
<CompileStageInputs Include="$(SrcDirectory)/**/project.json;$(SrcDirectory)/**/project.lock.json" />
<Stage Include="Stage1">
<Inputs>@(CompileStageInputs)</Inputs>
<StageDirectory>$(Stage1Directory)</StageDirectory>
<StageSymbolsDirectory>$(Stage1SymbolsDirectory)</StageSymbolsDirectory>
<DotnetExe>$(DotnetStage0)</DotnetExe>
</Stage>
<Stage Include="Stage2">
<Inputs>@(CompileStageInputs)</Inputs>
<StageDirectory>$(Stage2Directory)</StageDirectory>
<StageSymbolsDirectory>$(Stage2SymbolsDirectory)</StageSymbolsDirectory>
<DotnetExe>$(DotnetStage1)</DotnetExe>
</Stage>
</ItemGroup>
</Target>
<Target Name="CompileStage"
Inputs="%(Stage.Inputs)"
Outputs="%(StageDirectory)/sdk/$(SdkVersion)/dotnet.dll">
<PropertyGroup>
<DynamicLibPrefix Condition=" '$(OSName)' == 'win' "></DynamicLibPrefix>
<DynamicLibPrefix Condition=" '$(OSName)' != 'win' ">lib</DynamicLibPrefix>
<DynamicLibSuffix Condition=" '$(OSName)' == 'win' ">.dll</DynamicLibSuffix>
<DynamicLibSuffix Condition=" '$(OSName)' == 'osx' ">.dylib</DynamicLibSuffix>
<DynamicLibSuffix Condition=" '$(DynamicLibSuffix)' == '' ">.so</DynamicLibSuffix>
<DotnetHostBaseName>dotnet$(ExeExtension)</DotnetHostBaseName>
<DotnetHostFxrBaseName>$(DynamicLibPrefix)hostfxr$(DynamicLibSuffix)</DotnetHostFxrBaseName>
<HostPolicyBaseName>$(DynamicLibPrefix)hostpolicy$(DynamicLibSuffix)</HostPolicyBaseName>
<StageDirectory>%(Stage.StageDirectory)</StageDirectory>
<StageSymbolsDirectory>%(Stage.StageSymbolsDirectory)</StageSymbolsDirectory>
<SdkOutputDirectory>$(StageDirectory)/sdk/$(SdkVersion)</SdkOutputDirectory>
<BinaryToCorehostifyRelDir>runtimes/any/native</BinaryToCorehostifyRelDir>
<BinaryToCorehostifyOutDir>$(SdkOutputDirectory)/$(BinaryToCorehostifyRelDir)</BinaryToCorehostifyOutDir>
<MSBuildTargetsDirectory>$(SdkOutputDirectory)/runtimes/any/native</MSBuildTargetsDirectory>
<SharedFrameworkNameVersionPath>$(StageDirectory)/shared/$(SharedFrameworkName)/$(SharedFrameworkVersion)</SharedFrameworkNameVersionPath>
</PropertyGroup>
<ItemGroup>
<BinObj Include="$(SrcDirectory)/**/bin/**/*" />
<BinObj Include="$(SrcDirectory)/**/obj/**/*" />
<FilesToRemoveFromStageDirectory Include="$(StageDirectory)/**/*" />
<SharedFramework Include="$(SharedFrameworkPublishDirectory)/**/*" />
<BinariesToRemove Include="csc" />
<BinariesToRemove Include="vbc" />
</ItemGroup>
<Delete Files="@(BinObj)" />
<Delete Files="@(FilesToRemoveFromStageDirectory)" />
<RemoveDir Directories="$(StageDirectory)" />
<MakeDir Directories="$(StageDirectory)"/>
<!-- CopySharedFramework -->
<Copy SourceFiles="@(SharedFramework)"
DestinationFiles="@(SharedFramework->'$(StageDirectory)\%(RecursiveDir)%(Filename)%(Extension)')" />
<!-- Publish DotNet -->
<Exec Command="%(Stage.DotnetExe) publish
--native-subdirectory
--output $(SdkOutputDirectory)
--configuration $(Configuration)
--version-suffix $(CommitCount)
$(SrcDirectory)/dotnet" />
<!-- Corehostify Binaries -->
<FixModeFlags Dir="$(SdkOutputDirectory)" />
<Exec Command="%(Stage.DotnetExe) publish
--output $(SdkOutputDirectory)
--framework netcoreapp1.0
$(SrcDirectory)/compilers" />
<Copy SourceFiles="$(BinaryToCorehostifyOutDir)/csc.exe"
DestinationFiles="$(SdkOutputDirectory)/csc.dll" />
<Move SourceFiles="$(BinaryToCorehostifyOutDir)/csc.exe"
DestinationFiles="$(SdkOutputDirectory)/csc.exe" />
<Copy SourceFiles="$(SdkOutputDirectory)/compilers.deps.json"
DestinationFiles="$(SdkOutputDirectory)/csc.deps.json" />
<Copy SourceFiles="$(SdkOutputDirectory)/compilers.runtimeconfig.json"
DestinationFiles="$(SdkOutputDirectory)/csc.runtimeconfig.json" />
<ChangeEntryPointLibraryName
DepsFile="$(SdkOutputDirectory)/csc.deps.json"
NewName="csc.deps.json" />
<RemoveAssetFromDepsPackages DepsFile="$(SdkOutputDirectory)/csc.deps.json"
SectionName="runtimeTargets"
AssetPath="$(BinaryToCorehostifyRelDir)/%(BinariesToRemove.Identity).exe" />
<RemoveAssetFromDepsPackages DepsFile="$(SdkOutputDirectory)/dotnet.deps.json"
SectionName="runtimeTargets"
AssetPath="$(BinaryToCorehostifyRelDir)/%(BinariesToRemove.Identity).exe" />
<!-- cleanup compilers project output we don't need -->
<CleanPublishOutput Path="$(SdkOutputDirectory)"
Name="compilers"
DeleteRuntimeConfigJson="true"
DeleteDepsJson="true" />
<!-- Copy Host to SDK Directory -->
<Copy SourceFiles="$(SharedFrameworkNameVersionPath)/$(DotnetHostBaseName)"
DestinationFiles="$(SdkOutputDirectory)/corehost$(ExeExtension)" />
<Copy SourceFiles="$(SharedFrameworkNameVersionPath)/$(DotnetHostFxrBaseName)"
DestinationFiles="$(SdkOutputDirectory)/$(DotnetHostFxrBaseName)" />
<Copy SourceFiles="$(SharedFrameworkNameVersionPath)/$(HostPolicyBaseName)"
DestinationFiles="$(SdkOutputDirectory)/$(HostPolicyBaseName)" />
<CrossgenDirectory CoreCLRVersion="$(CoreCLRVersion)"
JitVersion="$(JitVersion)"
SharedFrameworkNameVersionPath="$(SharedFrameworkNameVersionPath)"
SdkOutputDirectory="$(SdkOutputDirectory)" />
<!-- Generate .version file -->
<WriteLinesToFile File="$(SdkOutputDirectory)/.version"
Lines="$(CommitHash);$(SdkVersion)"
Overwrite="true" />
<ItemGroup>
<MSBuildTargetsToCopy Include="$(MSBuildTargetsDirectory)/**/*.targets" />
<MSBuildTargetsToCopy Include="$(MSBuildTargetsDirectory)/**/*.Targets" />
<MSBuildTargetsToCopy Include="$(MSBuildTargetsDirectory)/**/*.props" />
<MSBuildTargetsToCopy Include="$(MSBuildTargetsDirectory)/**/*.overridetasks" />
<MSBuildTargetsToCopy Include="$(MSBuildTargetsDirectory)/**/*.tasks" />
</ItemGroup>
<Copy SourceFiles="@(MSBuildTargetsToCopy)"
DestinationFiles="@(MSBuildTargetsToCopy->'$(SdkOutputDirectory)\%(RecursiveDir)%(Filename)%(Extension)')" />
<ItemGroup>
<FilesToClean Include="$(StageDirectory)/sdk/**/vbc.exe" />
</ItemGroup>
<Delete Files="@(FilesToClean)" />
<ItemGroup>
<FilesToCopy Include="$(StageDirectory)/**/*" />
<PdbsToClean Include="$(StageDirectory)/sdk/**/*.pdb" />
</ItemGroup>
<Copy SourceFiles="@(FilesToCopy)"
DestinationFiles="@(FilesToCopy->'$(StageSymbolsDirectory)\%(RecursiveDir)%(Filename)%(Extension)')" />
<Delete Files="@(PdbsToClean)" />
</Target>
</Project>