Decompose Crossgen, remove CleanPublishOutput, replace ExtractArchive with *FileExtractToDirectory (#3927)

* Eliminate CleanPublishOutput

* Decompose Crossgen Task

* WiP

* TarGzFileExtractToDirectory

* FixModeFlags --> CHMod

Also various eliminations of dead code

* Tasks cleanup

Move all tasks to .tasks file. There is little value in keepint them in each source file as they are already being used assumptively by files that happen to get executed later.

Also eliminating uses of <Exec> for DotNet invocations

* Move to BuildTools implementation of TarGzCreateFromDirectory

* Eliminate Command.cs and helpers

* Remove dead code

* Revert TarGz from BuildTools

Latest build tools package has not picked up the task, though it is checked in.

* Disable ChMod on Windows

* Windows bug fix

* PR Feedback

* Finish changing Chmod caps
This commit is contained in:
Piotr Puszkiewicz 2016-07-26 00:29:59 -04:00 committed by GitHub
parent ee8a01b8d6
commit 5ebc6a1ceb
50 changed files with 827 additions and 1645 deletions

View file

@ -1 +1 @@
1.0.26-prerelease-00607-01
1.0.26-prerelease-00621-06

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="BuildTheWholeCli" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="build/Microsoft.DotNet.Cli.Monikers.props" />
<PropertyGroup>
<!--
$(OS) is set to Unix/Windows_NT. This comes from an environment variable on Windows and MSBuild on Unix.
@ -29,10 +29,11 @@
<CoreCLRVersion>1.0.2</CoreCLRVersion>
<JitVersion>1.0.2</JitVersion>
<Stage0Path>$(RepoRoot)/.dotnet_stage0/$(Architecture)</Stage0Path>
<ExeExtension>.exe</ExeExtension>
<ExeExtension Condition=" '$(OS)' != 'Windows_NT' "></ExeExtension>
<DotnetStage0>$(Stage0Path)/dotnet$(ExeExtension)</DotnetStage0>
<Stage0Directory>$(RepoRoot)/.dotnet_stage0/$(Architecture)</Stage0Directory>
<DotnetStage0>$(Stage0Directory)/dotnet$(ExeExtension)</DotnetStage0>
<DotnetCliBuildDirectory>$(RepoRoot)/build_projects/dotnet-cli-build</DotnetCliBuildDirectory>
</PropertyGroup>
@ -56,7 +57,7 @@
RestoreDotnetCliBuildFramework">
<ItemGroup>
<DotnetSdkDirectories Include="$([System.IO.Directory]::GetDirectories(&quot;$(Stage0Path)/sdk&quot;))" />
<DotnetSdkDirectories Include="$([System.IO.Directory]::GetDirectories(&quot;$(Stage0Directory)/sdk&quot;))" />
<AzureStorageToCopy Include="@(DotnetSdkDirectories)">
<Source>$(DotnetCliBuildDirectory)/bin/Microsoft.WindowsAzure.Storage.dll</Source>
<Destination>%(Identity)/Microsoft.WindowsAzure.Storage.dll</Destination>
@ -82,6 +83,6 @@
<Import Project="build/Microsoft.DotNet.Cli.Prepare.targets" />
<Import Project="build/Microsoft.DotNet.Cli.Compile.targets" />
<Import Project="build/Microsoft.DotNet.Cli.Package.targets" />
<Import Project="build/Microsoft.DotNet.Cli.Test.targets" />
<Import Project="build/Microsoft.DotNet.Cli.Test.targets" />
<Import Project="build/Microsoft.DotNet.Cli.Publish.targets" />
</Project>

View file

@ -1,12 +1,11 @@
<?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" />
<Import Project="crossgen/Microsoft.DotNet.Cli.Crossgen.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)" />
<ItemGroup>
<PublishOutputExtensions Include="$(ExeExtension);.dll;.pdb;.deps.json;.runtimeconfig.json" />
</ItemGroup>
<Target Name="Compile" DependsOnTargets="Prepare;
SetupStage;
@ -14,7 +13,8 @@
BuildProjectsForNuGetPackages;
GenerateNuGetPackagesArchive" />
<Target Name="SetupStage">
<Target Name="SetupStage"
DependsOnTargets="Prepare">
<PropertyGroup>
<SrcDirectory>$(RepoRoot)/src</SrcDirectory>
</PropertyGroup>
@ -27,18 +27,20 @@
<Inputs>@(CompileStageInputs)</Inputs>
<StageDirectory>$(Stage1Directory)</StageDirectory>
<StageSymbolsDirectory>$(Stage1SymbolsDirectory)</StageSymbolsDirectory>
<DotnetExe>$(DotnetStage0)</DotnetExe>
<DotnetDir>$(Stage0Directory)</DotnetDir>
</Stage>
<Stage Include="Stage2">
<Inputs>@(CompileStageInputs)</Inputs>
<StageDirectory>$(Stage2Directory)</StageDirectory>
<StageSymbolsDirectory>$(Stage2SymbolsDirectory)</StageSymbolsDirectory>
<DotnetExe>$(DotnetStage1)</DotnetExe>
</Stage>
</ItemGroup>
</Target>
<DotnetDir>$(Stage1Directory)</DotnetDir>
</Stage>
</ItemGroup>
</Target>
<Target Name="CompileStage"
DependsOnTargets="SetupStage;
InitCrossgenProps;"
Inputs="%(Stage.Inputs)"
Outputs="%(StageDirectory)/sdk/$(SdkVersion)/dotnet.dll">
<PropertyGroup>
@ -55,21 +57,26 @@
<StageDirectory>%(Stage.StageDirectory)</StageDirectory>
<StageSymbolsDirectory>%(Stage.StageSymbolsDirectory)</StageSymbolsDirectory>
<SdkOutputDirectory>$(StageDirectory)/sdk/$(SdkVersion)</SdkOutputDirectory>
<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 Remove="*" />
<BinObj Include="$(SrcDirectory)/**/bin/**/*" />
<BinObj Include="$(SrcDirectory)/**/obj/**/*" />
<FilesToRemoveFromStageDirectory Remove="*" />
<FilesToRemoveFromStageDirectory Include="$(StageDirectory)/**/*" />
<SharedFramework Remove="*" />
<SharedFramework Include="$(SharedFrameworkPublishDirectory)/**/*" />
<BinariesToRemove Remove="*" />
<BinariesToRemove Include="csc" />
<BinariesToRemove Include="vbc" />
</ItemGroup>
@ -83,22 +90,45 @@
<!-- 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" />
<DotNetPublish ToolPath="%(Stage.DotnetDir)"
NativeSubdirectory="True"
Output="$(SdkOutputDirectory)"
Configuration="$(Configuration)"
VersionSuffix="$(CommitCount)"
ProjectPath="$(SrcDirectory)/dotnet" />
<!-- Corehostify Binaries -->
<FixModeFlags Dir="$(SdkOutputDirectory)" />
<ItemGroup Condition=" '$(OSName)' != 'win' ">
<SdkOutputChmodTargets Remove="*" />
<SdkOutputChmodTargets Include="$(SdkOutputDirectory)/**/*.exe;
$(SdkOutputDirectory)/**/*.dll" >
<!-- Managed assemblies do not need execute -->
<Mode>u=rw,g=r,o=r</Mode>
</SdkOutputChmodTargets>
<Exec Command="%(Stage.DotnetExe) publish
--output $(SdkOutputDirectory)
--framework netcoreapp1.0
$(SrcDirectory)/compilers" />
<SdkOutputChmodTargets Include="$(SdkOutputDirectory)/**/*.dylib;
$(SdkOutputDirectory)/**/*.so" >
<!-- Generally, dylibs and sos have 'x' -->
<Mode>u=rwx,g=rx,o=rx</Mode>
</SdkOutputChmodTargets>
<SdkOutputChmodTargets Include="$(SdkOutputDirectory)/**/*"
Exclude="$(SdkOutputDirectory)/**/*.*" >
<!-- Executables need x -->
<Mode>u=rwx,g=rx,o=rx</Mode>
</SdkOutputChmodTargets>
</ItemGroup>
<Chmod Condition=" '$(OSName)' != 'win' "
File="%(SdkOutputChModTargets.FullPath)"
Mode="%(SdkOutputChModTargets.Mode)" />
<DotNetPublish ToolPath="%(Stage.DotnetDir)"
Output="$(SdkOutputDirectory)"
Framework="netcoreapp1.0"
ProjectPath="$(SrcDirectory)/compilers" />
<Copy SourceFiles="$(BinaryToCorehostifyOutDir)/csc.exe"
DestinationFiles="$(SdkOutputDirectory)/csc.dll" />
@ -112,7 +142,7 @@
<Copy SourceFiles="$(SdkOutputDirectory)/compilers.runtimeconfig.json"
DestinationFiles="$(SdkOutputDirectory)/csc.runtimeconfig.json" />
<ChangeEntryPointLibraryName
<ChangeEntryPointLibraryName
DepsFile="$(SdkOutputDirectory)/csc.deps.json"
NewName="csc.deps.json" />
@ -124,10 +154,7 @@
AssetPath="$(BinaryToCorehostifyRelDir)/%(BinariesToRemove.Identity).exe" />
<!-- cleanup compilers project output we don't need -->
<CleanPublishOutput Path="$(SdkOutputDirectory)"
Name="compilers"
DeleteRuntimeConfigJson="true"
DeleteDepsJson="true" />
<Delete Files="$(SdkOutputDirectory)/compilers%(PublishOutputExtensions.Identity)" />
<!-- Copy Host to SDK Directory -->
<Copy SourceFiles="$(SharedFrameworkNameVersionPath)/$(DotnetHostBaseName)"
@ -139,10 +166,37 @@
<Copy SourceFiles="$(SharedFrameworkNameVersionPath)/$(HostPolicyBaseName)"
DestinationFiles="$(SdkOutputDirectory)/$(HostPolicyBaseName)" />
<CrossgenDirectory CoreCLRVersion="$(CoreCLRVersion)"
JitVersion="$(JitVersion)"
SharedFrameworkNameVersionPath="$(SharedFrameworkNameVersionPath)"
SdkOutputDirectory="$(SdkOutputDirectory)" />
<!-- Crossgen the Shared Framework -->
<ItemGroup>
<SdkFiles Remove="*" />
<SdkFiles Include="$(SdkOutputDirectory)/**/*" />
<SdkFilesWithPEMarker Remove="*" />
</ItemGroup>
<AddMetadataIsPE Items="@(SdkFiles)">
<Output TaskParameter="ResultItems" ItemName="SdkFilesWithPEMarker" />
</AddMetadataIsPE>
<ItemGroup>
<CrossgenTargets Remove="*" />
<CrossgenTargets Include="%(SdkFilesWithPEMarker.FullPath)" Condition=" '%(SdkFilesWithPEMarker.IsPE)' == 'True' " />
<CompileStageSdkDirectories Remove="*" />
</ItemGroup>
<RemoveDuplicates Inputs="@(SdkFiles->'%(RootDir)%(Directory)')">
<Output TaskParameter="Filtered" ItemName="CompileStageSdkDirectories" />
</RemoveDuplicates>
<Crossgen Condition=" '$(DISABLE_CROSSGEN)' != '1' "
SourceAssembly="%(CrossgenTargets.FullPath)"
DestinationPath="%(CrossgenTargets.FullPath)"
JITPath="$(LibCLRJitPath)"
CrossgenPath="$(CrossgenPath)"
ReadyToRun="True"
PlatformAssemblyPaths="@(PlatformAssemblies);
$(SharedFrameworkNameVersionPath);
@(CompileStageSdkDirectories)" />
<!-- Generate .version file -->
<WriteLinesToFile File="$(SdkOutputDirectory)/.version"

View file

@ -1,16 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="GetCurrentRuntimeInformation" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="GenerateBuildVersionInfo" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="SetEnvVar" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="DotNetBuild" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="DotNetPack" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="DotNetRestore" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="DotNetTest" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="DownloadFile" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="ExtractArchive" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="ZipFileCreateFromDirectory" AssemblyFile="$(BuildToolsDir)/Microsoft.DotNet.Build.Tasks.dll"/>
<Import Project="Microsoft.DotNet.Cli.tasks" />
<Import Project="prepare/CheckPrereqs.targets" />
<Target Name="Prepare"
@ -32,11 +22,17 @@
<Output TaskParameter="OSName" PropertyName="OSName" />
</GetCurrentRuntimeInformation>
<!-- NuGet Information -->
<PropertyGroup>
<NuGetPackagesDir>$(NUGET_PACKAGES)</NuGetPackagesDir>
<NuGetPackagesDir Condition=" '$(NuGetPackagesDir)' == '' ">$(RepoRoot)/.nuget/packages</NuGetPackagesDir>
</PropertyGroup>
<!-- Common Properties -->
<PropertyGroup>
<IsDesktopAvailable>False</IsDesktopAvailable>
<IsDesktopAvailable Condition=" '$(OSName)' == 'win' ">True</IsDesktopAvailable>
<DotNetPath>$(Stage0Path)</DotNetPath>
<DotNetPath>$(Stage0Directory)</DotNetPath>
<BaseOutputDirectory>$(RepoRoot)/artifacts/$(Rid)</BaseOutputDirectory>
<ToolsOutputDirectory>$(BaseOutputDirectory)/tools</ToolsOutputDirectory>
@ -53,11 +49,14 @@
<SharedFrameworkPublishDirectory>$(IntermediateDirectory)/sharedFrameworkPublish</SharedFrameworkPublishDirectory>
</PropertyGroup>
<GetCommitHash RepoRoot="$(RepoRoot)">
<Output TaskParameter="CommitHash" PropertyName="CommitHash" />
</GetCommitHash>
<GenerateBuildVersionInfo RepoRoot="$(RepoRoot)">
<Output TaskParameter="VersionMajor" PropertyName="VersionMajor" />
<Output TaskParameter="VersionMinor" PropertyName="VersionMinor" />
<Output TaskParameter="VersionPatch" PropertyName="VersionPatch" />
<Output TaskParameter="CommitHash" PropertyName="CommitHash" />
<Output TaskParameter="CommitCount" PropertyName="CommitCount" />
<Output TaskParameter="ReleaseSuffix" PropertyName="ReleaseSuffix" />
<Output TaskParameter="VersionSuffix" PropertyName="VersionSuffix" />
@ -91,6 +90,12 @@
<ProductMonikerRid Condition=" '$(Rid)' == 'ubuntu.16.04-x64' Or '$(Rid)' == 'fedora.23-x64' Or '$(Rid)' == 'opensuse.13.2-x64' ">$(Rid)</ProductMonikerRid>
<ProductMonikerRid Condition=" '$(ProductMonikerRid)' == '' ">$(OSName)-$(Architecture)</ProductMonikerRid>
<DynamicLibPrefix>lib</DynamicLibPrefix>
<DynamicLibPrefix Condition=" '$(OSName)' == 'win' "></DynamicLibPrefix>
<DynamicLibExtension>.so</DynamicLibExtension>
<DynamicLibExtension Condition=" '$(OSName)' == 'win' ">.dll</DynamicLibExtension>
<DynamicLibExtension Condition=" '$(OSName)' == 'osx' ">.dylib</DynamicLibExtension>
<ArtifactNameSdk>dotnet-sdk</ArtifactNameSdk>
<ArtifactNameSdkDebug>dotnet-sdk-debug</ArtifactNameSdkDebug>
<ArtifactNameCombinedHostHostFxrFrameworkSdk>dotnet-dev</ArtifactNameCombinedHostHostFxrFrameworkSdk>
@ -133,14 +138,14 @@
Condition="!Exists('$(CombinedSharedHostAndFrameworkArchive)')">
<Url>$(SharedFrameworkArchiveBlobRootUrl)/$(CombinedFrameworkHostCompressedFileName)</Url>
<DownloadFileName>$(CombinedSharedHostAndFrameworkArchive)</DownloadFileName>
<ExtractDestintation>$(SharedFrameworkPublishDirectory)</ExtractDestintation>
<ExtractDestination>$(SharedFrameworkPublishDirectory)</ExtractDestination>
</_DownloadAndExtractItem>
<_DownloadAndExtractItem Include="DownloadedSharedFrameworkInstallerFile"
Condition="!Exists('$(DownloadedSharedFrameworkInstallerFile)') And '$(InstallerExtension)' != ''">
<Url>$(CoreSetupInstallerBlobRootUrl)/$(SharedFrameworkVersion)/$(DownloadedSharedFrameworkInstallerFileName)</Url>
<DownloadFileName>$(DownloadedSharedFrameworkInstallerFile)</DownloadFileName>
<ExtractDestintation></ExtractDestintation>
<ExtractDestination></ExtractDestination>
</_DownloadAndExtractItem>
<_DownloadAndExtractItem Include="DownloadedSharedHostInstallerFile"
@ -166,9 +171,15 @@
Uri="%(_DownloadAndExtractItem.Url)"
DestinationPath="%(_DownloadAndExtractItem.DownloadFileName)" />
<ExtractArchive Condition=" '%(_DownloadAndExtractItem.ExtractDestintation)' != '' "
InputFile="%(_DownloadAndExtractItem.DownloadFileName)"
DestinationDirectory="%(_DownloadAndExtractItem.ExtractDestintation)" />
<ZipFileExtractToDirectory Condition=" '%(_DownloadAndExtractItem.ExtractDestination)' != '' AND '$(OSName)' == 'win' "
SourceArchive="%(_DownloadAndExtractItem.DownloadFileName)"
DestinationDirectory="%(_DownloadAndExtractItem.ExtractDestination)"
OverwriteDestination="True" />
<TarGzFileExtractToDirectory Condition=" '%(_DownloadAndExtractItem.ExtractDestination)' != '' AND '$(OSName)' != 'win' "
SourceArchive="%(_DownloadAndExtractItem.DownloadFileName)"
DestinationDirectory="%(_DownloadAndExtractItem.ExtractDestination)"
OverwriteDestination="True" />
</Target>
<Target Name="RestorePackages"

View file

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Test" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="AddMetadataIsPE" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="ChangeEntryPointLibraryName" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="ChMod" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="Crossgen" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="DotNetBuild" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="DotNetNew" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="DotNetPack" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="DotNetPublish" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="DotNetRestore" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="DotNetTest" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="DownloadFile" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="FinalizeBuild" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="GenerateBuildVersionInfo" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="GenerateGuidFromName" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="GetCommitHash" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="GetCurrentRuntimeInformation" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="MakeRelative" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="RemoveAssetFromDepsPackages" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="ReplaceFileContents" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="SetBlobPropertiesBasedOnFileType" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="SetEnvVar" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="TarGzFileCreateFromDirectory" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="TarGzFileExtractToDirectory" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="UploadToAzure" AssemblyFile="$(BuildToolsTaskDir)/Microsoft.DotNet.Build.CloudTestTasks.dll"/>
<UsingTask TaskName="ZipFileCreateFromDirectory" AssemblyFile="$(BuildToolsDir)/Microsoft.DotNet.Build.Tasks.dll"/>
<UsingTask TaskName="ZipFileExtractToDirectory" AssemblyFile="$(BuildToolsDir)/Microsoft.DotNet.Build.Tasks.dll"/>
</Project>

View file

@ -13,15 +13,20 @@
<RemoveDir Directories="$(NuGetPackagesArchiveProject);$(NuGetPackagesArchiveFolder)" />
<MakeDir Directories="$(NuGetPackagesArchiveProject);$(NuGetPackagesArchiveFolder)"/>
<Exec Command="$(DotnetStage2) new" WorkingDirectory="$(NuGetPackagesArchiveProject)" />
<Exec Command="$(DotnetStage2) restore --packages $(NuGetPackagesArchiveFolder)"
WorkingDirectory="$(NuGetPackagesArchiveProject)" />
<DotNetNew ToolPath="$(Stage2Directory)"
WorkingDirectory="$(NuGetPackagesArchiveProject)" />
<DotNetRestore ToolPath="$(Stage2Directory)"
Packages="$(NuGetPackagesArchiveFolder)"
WorkingDirectory="$(NuGetPackagesArchiveProject)" />
<Delete Files="$(IntermediateArchive);$(IntermediateArchive).zip" />
<Message Text="Publishing Archiver" />
<Exec Command="$(DotnetStage2) publish --output $(ToolsOutputDirectory) --configuration $(Configuration)"
WorkingDirectory="$(RepoRoot)/tools/Archiver" />
<DotNetPublish ToolPath="$(Stage2Directory)"
WorkingDirectory="$(RepoRoot)/tools/Archiver"
Output="$(ToolsOutputDirectory)"
Configuration="$(Configuration)" />
<Exec Command="$(ArchiverExe) -a $(IntermediateArchive) $(NuGetPackagesArchiveFolder)" />

View file

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="InitCrossgenProps"
DependsOnTargets="Init">
<PropertyGroup>
<CoreCLRRid>$(Rid)</CoreCLRRid>
<CoreCLRRid Condition=" '$(OSName)' == 'win' ">win7-$(Architecture)</CoreCLRRid>
<CoreCLRRid Condition=" '$(OSName)' == 'osx' ">osx.10.10-x64</CoreCLRRid>
<CoreCLRRid Condition=" '$(OSName)' == 'centos' OR '$(OSName)' == 'rhel' ">rhel.7-x64</CoreCLRRid>
<CrossGenPackageName>runtime.$(CoreCLRRid).Microsoft.NETCore.Runtime.CoreCLR</CrossGenPackageName>
<LibCLRJitPackageName>runtime.$(CoreCLRRid).Microsoft.NETCore.Jit</LibCLRJitPackageName>
<CoreCLRPackageName>runtime.$(CoreCLRRid).Microsoft.NETCore.Runtime.CoreCLR</CoreCLRPackageName>
<CoreCLRLibsDir>$(NuGetPackagesDir)/$(CoreCLRPackageName)/$(CoreCLRVersion)/runtimes/$(CoreCLRRid)/lib/netstandard1.0</CoreCLRLibsDir>
<CrossgenPath>$(NuGetPackagesDir)/$(CrossGenPackageName)/$(CoreCLRVersion)/tools/crossgen$(ExeExtension)</CrossgenPath>
<LibCLRJitPath>$(NuGetPackagesDir)/$(LibCLRJitPackageName)/$(CoreCLRVersion)/runtimes/$(CoreCLRRid)/native/$(DynamicLibPrefix)clrjit$(DynamicLibExtension)</LibCLRJitPath>
</PropertyGroup>
<ItemGroup>
<PlatformAssemblies Include="$(CoreCLRLibsDir)" />
</ItemGroup>
</Target>
</Project>

View file

@ -1,9 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Layout" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="ZipFileCreateFromDirectory" AssemblyFile="$(BuildToolsDir)/Microsoft.DotNet.Build.dll"/>
<UsingTask TaskName="TarGzFileCreateFromDirectory" AssemblyFile="$(CLIBuildDll)" />
<Target Name="GenerateArchives"
DependsOnTargets="Init;
Layout;
@ -32,7 +28,7 @@
</Target>
<Target Name="SetupGenerateArchivesInputsOutputs"
<Target Name="SetupGenerateArchivesInputsOutputs"
DependsOnTargets="Init">
<PropertyGroup>
<ArchiveOutputDirectory>$(PackagesDirectory)</ArchiveOutputDirectory>

View file

@ -1,13 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="SetupGenerateDebInputsOutputs">
<Exec Command="/usr/bin/env debuild -h" ContinueOnError="true">
<Output TaskParameter="ExitCode" PropertyName="DebuildExitCode" />
</Exec>
<!-- Workaround for Ubuntu16 Jenkins https://github.com/dotnet/core-setup/issues/167 -->
<Message Condition=" '$(DebuildPresent)' != 'true' "
<Message Condition=" '$(DebuildPresent)' != 'true' "
Text="Debuild Not found, Debian packages will not be built."
Importance="High" />
@ -17,10 +16,10 @@
<DebianPackagingScript>$(RepoRoot)/scripts/package/package-debian.sh</DebianPackagingScript>
<ManpagesDirectory>$(RepoRoot)/Documentation/manpages</ManpagesDirectory>
<InstallerOutputDirectory>$(PackagesDirectory)</InstallerOutputDirectory>
<SdkInstallerFile>$(InstallerOutputDirectory)/$(ArtifactNameWithVersionSdk)$(InstallerExtension)</SdkInstallerFile>
<SdkDebianPackageName>dotnet-dev-$(SdkVersion)</SdkDebianPackageName>
<SharedFrameworkDebianPackageName>dotnet-sharedframework-$(SharedFrameworkName)-$(SharedFrameworkVersion)</SharedFrameworkDebianPackageName>
<SharedFrameworkDebianPackageName>$(SharedFrameworkDebianPackageName.ToLower())</SharedFrameworkDebianPackageName>
@ -29,7 +28,7 @@
<SharedHostDebianPackageName>dotnet-host</SharedHostDebianPackageName>
<SdkDebianIntermediateDirectory>$(IntermediateDirectory)/debian/sdk</SdkDebianIntermediateDirectory>
<DebianTestResultsXmlFile>$(SdkDebianIntermediateDirectory)/debian-testResults.xml</DebianTestResultsXmlFile>
<DebianInstalledDirectory>/usr/share/dotnet</DebianInstalledDirectory>
<EndToEndTestDirectory>$(RepoRoot)/test/EndToEnd</EndToEndTestDirectory>
@ -42,14 +41,14 @@
<!-- Consumed By Publish -->
<ItemGroup>
<GeneratedInstallers Include="$(SdkInstallerFile)" />
</ItemGroup>
</ItemGroup>
<ItemGroup>
<SdkDebInputFiles Include="$(SdkLayoutOutputDirectory)/**/*" />
</ItemGroup>
</Target>
<Target Name="GenerateSdkDeb"
<Target Name="GenerateSdkDeb"
Condition=" '$(OSName)' == 'ubuntu' and '$(DebuildPresent)' == 'true' "
Inputs="@(SdkDebInputFiles);"
Outputs="$(SdkInstallerFile)" >
@ -78,7 +77,7 @@
<Exec Command="sudo dpkg -r $(SharedHostDebianPackageName)" />
</Target>
<Target Name="TestSdkDeb"
<Target Name="TestSdkDeb"
Condition=" '$(OSName)' == 'ubuntu' and '$(DebuildPresent)' == 'true' "
Inputs="$(DownloadedSharedHostInstallerFile);
$(DownloadedHostFxrInstallerFile);
@ -105,7 +104,7 @@
<Exec Command="sudo dpkg -r $(SharedHostDebianPackageName)" />
</Target>
<Target Name="GenerateDebs"
<Target Name="GenerateDebs"
DependsOnTargets="Init;
Layout;
SetupGenerateDebInputsOutputs;

View file

@ -1,10 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="DownloadFile" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="ExtractArchive" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="GenerateGuidFromName" AssemblyFile="$(CLIBuildDll)" />
<Target Name="MsiTargetsSetupInputOutputs" DependsOnTargets="Init">
<!-- AcquireWix Properties -->
<PropertyGroup>
@ -50,7 +45,7 @@
</PropertyGroup>
</Target>
<Target Name="AcquireWix"
<Target Name="AcquireWix"
DependsOnTargets="Init;MsiTargetsSetupInputOutputs"
Inputs="$(WixDownloadSentinel)"
Outputs="$(WixDestinationPath)">
@ -62,14 +57,14 @@
Lines="$(WixVersion)"
Overwrite="true"
Encoding="Unicode"/>
<DownloadFile
Uri="$(WixDownloadUrl)"
DestinationPath="$(WixDestinationPath)"
Overwrite="false" />
<ExtractArchive
InputFile="$(WixDestinationPath)"
<ZipFileExtractToDirectory
SourceArchive="$(WixDestinationPath)"
DestinationDirectory="$(WixRoot)" />
</Target>
@ -118,7 +113,7 @@
'$(Architecture)'" />
</Target>
<Target Name="TestSdkMsi"
<Target Name="TestSdkMsi"
Inputs="$(SdkInstallerFile)"
Outputs="$(SdkMsiTestedSentinel)"
DependsOnTargets="Init;MsiTargetsSetupInputOutputs;GenerateSdkMsi"
@ -135,7 +130,7 @@
Encoding="Unicode"/>
</Target>
<Target Name="GenerateMsis"
<Target Name="GenerateMsis"
DependsOnTargets="Init;
Layout;
MsiTargetsSetupInputOutputs;
@ -147,14 +142,14 @@
<!-- These targets are used in signing, don't remove them! -->
<Target Name="ExtractEngineFromSdkBundle">
<Exec Command="$(WixRoot)/insignia.exe
-ib $(CombinedFrameworkSdkHostInstallerFile)
<Exec Command="$(WixRoot)/insignia.exe
-ib $(CombinedFrameworkSdkHostInstallerFile)
-o $(CombinedFrameworkSdkHostBundleEngineName)" />
</Target>
<Target Name="ReattachEngineToSdkBundle">
<Exec Command="$(WixRoot)/insignia.exe
-ab $(CombinedFrameworkSdkHostInstallerFile)
<Exec Command="$(WixRoot)/insignia.exe
-ab $(CombinedFrameworkSdkHostInstallerFile)
-o $(CombinedFrameworkSdkHostBundleEngineName)" />
</Target>
</Project>

View file

@ -1,7 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="ReplaceFileContents" AssemblyFile="$(CLIBuildDll)" />
<Target Name="SetupPkgInputsOutputs">
<PropertyGroup>
<InstallerOutputDirectory>$(PackagesDirectory)</InstallerOutputDirectory>
@ -9,23 +7,23 @@
<SdkInstallerFile>$(InstallerOutputDirectory)/$(ArtifactNameWithVersionSdk)$(InstallerExtension)</SdkInstallerFile>
<CombinedFrameworkSdkHostInstallerFile>$(InstallerOutputDirectory)/$(ArtifactNameWithVersionCombinedHostHostFxrFrameworkSdk)$(BundleExtension)</CombinedFrameworkSdkHostInstallerFile>
<!-- Properties for pkg build -->
<SharedHostComponentId>com.microsoft.dotnet.sharedhost.component.osx.x64</SharedHostComponentId>
<HostFxrComponentId>com.microsoft.dotnet.hostfxr.component.osx.x64</HostFxrComponentId>
<SharedFrameworkComponentId>com.microsoft.dotnet.sharedframework.$(SharedFrameworkNugetName).$(SharedFrameworkVersion).component.osx.x64</SharedFrameworkComponentId>
<SdkComponentId>com.microsoft.dotnet.dev.$(SdkVersion).component.osx.x64</SdkComponentId>
<SdkProductArchiveId>com.microsoft.dotnet.dev.$(SdkVersion).osx.x64</SdkProductArchiveId>
<PkgInstallDirectory>/usr/local/share/dotnet</PkgInstallDirectory>
<SdkPkgSourcesRootDirectory>$(RepoRoot)/packaging/osx/clisdk</SdkPkgSourcesRootDirectory>
<SdkPkgScriptsDirectory>$(SdkPkgSourcesRootDirectory)/scripts</SdkPkgScriptsDirectory>
<SdkProductArchiveResourcesDirectory>$(SdkPkgSourcesRootDirectory)/resources</SdkProductArchiveResourcesDirectory>
<SdkProductArchiveDistributionTemplateFile>$(SdkPkgSourcesRootDirectory)/Distribution-Template</SdkProductArchiveDistributionTemplateFile>
<SdkProductArchiveDistributionFile>$(PkgIntermediateDirectory)/CLI-SDK-Formatted-Distribution-Template.xml</SdkProductArchiveDistributionFile>
<SdkPkgIntermediatePath>$(PkgIntermediateDirectory)/$(SdkComponentId).pkg</SdkPkgIntermediatePath>
<SharedFrameworkPkgIntermediatePath>$(PkgIntermediateDirectory)/$(SharedFrameworkComponentId).pkg</SharedFrameworkPkgIntermediatePath>
<SharedHostPkgIntermediatePath>$(PkgIntermediateDirectory)/$(SharedHostComponentId).pkg</SharedHostPkgIntermediatePath>
@ -80,12 +78,12 @@
</ItemGroup>
</Target>
<Target Name="GenerateSdkPkg"
<Target Name="GenerateSdkPkg"
Inputs="@(GenerateSdkPkgInputs)"
Outputs="$(SdkInstallerFile)"
DependsOnTargets="Init;Layout;SetupPkgInputsOutputs"
Condition=" '$(OSName)' == 'osx' ">
<Exec Command="pkgbuild
--root '$(SdkLayoutOutputDirectory)'
--identifier '$(SdkComponentId)'
@ -101,7 +99,7 @@
DependsOnTargets="GenerateSdkPkg"
Condition=" '$(OSName)' == 'osx' ">
<!-- Move ProductArchive pkg components into place with component ids in the filenames -->
<Copy
<Copy
SourceFiles="$(SdkInstallerFile);
$(DownloadedSharedFrameworkInstallerFile);
$(DownloadedHostFxrInstallerFile);
@ -110,14 +108,14 @@
$(SharedFrameworkPkgIntermediatePath);
$(HostFxrPkgIntermediatePath);
$(SharedHostPkgIntermediatePath);" />
<!-- Fill out parameters in the Distribution Template -->
<ReplaceFileContents
InputFile="$(SdkProductArchiveDistributionTemplateFile)"
DestinationFile="$(SdkProductArchiveDistributionFile)"
ReplacementPatterns="@(DistributionTemplateReplacement -> '%(Identity)')"
ReplacementStrings="@(DistributionTemplateReplacement -> '%(ReplacementString)')" />
<Exec Command="productbuild
--version '$(SdkVersion)'
--identifier '$(SdkProductArchiveId)'
@ -127,7 +125,7 @@
'$(CombinedFrameworkSdkHostInstallerFile)'" />
</Target>
<Target Name="GeneratePkgs"
<Target Name="GeneratePkgs"
DependsOnTargets="Init;
Layout;
SetupPkgInputsOutputs;

View file

@ -1,8 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="MakeRelative" AssemblyFile="$(CLIBuildDll)" />
<Target DependsOnTargets="Init" Name="SetupLayoutInputsOutputs" >
<PropertyGroup>
<LayoutDirectory>$(IntermediateDirectory)/layouts</LayoutDirectory>
@ -61,7 +58,7 @@
<LayoutDefinition Include="CombinedHostHostFxrFrameworkSdk">
<InputFiles>@(CombinedHostHostFxrFrameworkSdkInput)</InputFiles>
<OutputFiles>@(CombinedHostHostFxrFrameworkSdkRelativeOutputFiles -> '$(CombinedHostHostFxrFrameworkSdkOutputDirectory)/%(Identity)')</OutputFiles>
<OutputFiles>@(CombinedHostHostFxrFrameworkSdkRelativeOutputFiles -> '$(CombinedHostHostFxrFrameworkSdkOutputDirectory)/%(Identity)')</OutputFiles>
<NameWithVersion>$(ArtifactNameWithVersionCombinedHostHostFxrFrameworkSdk)</NameWithVersion>
<Name>$(ArtifactNameCombinedHostHostFxrFrameworkSdk)</Name>
</LayoutDefinition>
@ -76,13 +73,13 @@
</ItemGroup>
</Target>
<Target Name="Layout"
<Target Name="Layout"
DependsOnTargets="Init;SetupLayoutInputsOutputs"
Inputs="@(LayoutDefinition -> '%(InputFiles)')"
Inputs="@(LayoutDefinition -> '%(InputFiles)')"
Outputs="@(LayoutDefinition -> '%(OutputFiles)')" >
<!-- Copy Files to layout directories based on defintiions -->
<Copy SourceFiles="%(LayoutDefinition.InputFiles)"
<Copy SourceFiles="%(LayoutDefinition.InputFiles)"
DestinationFiles="%(LayoutDefinition.OutputFiles)"
SkipUnchangedFiles="true" />
</Target>

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Layout" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="SetupProjectsToPack"
DependsOnTargets="Init">
<PropertyGroup>
@ -9,7 +9,7 @@
<PackagingBuildBasePath>$(Stage2CompilationDirectory)/forPackaging</PackagingBuildBasePath>
<NupkgOutputDirectory>$(PackagesDirectory)</NupkgOutputDirectory>
</PropertyGroup>
<ItemGroup>
<ProjectsToPack Include="$(ProjectsSrcDirectory)/Microsoft.DotNet.Cli.Utils" >
<ProjectName>Microsoft.DotNet.Cli.Utils</ProjectName>
@ -74,13 +74,13 @@
<Target Name="BuildProjectsForNuGetPackages"
DependsOnTargets="Init;
SetupProjectsToPack"
SetupProjectsToPack"
Condition=" '$(OS)' == 'Windows_NT' ">
<MakeDir Directories="$(PackagingBuildBasePath)" />
<Exec Command="$(DotnetStage2) build
--build-base-path $(PackagingBuildBasePath)
--configuration $(Configuration)
%(ProjectsToPack.Identity)" />
<DotNetBuild ToolPath="$(Stage2Directory)"
BuildBasePath="$(PackagingBuildBasePath)"
Configuration="$(Configuration)"
ProjectPath="%(ProjectsToPack.Identity)" />
</Target>
</Project>

View file

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<CentosCoreclrAndCoreFxDependencies Include="unzip" />
<CentosCoreclrAndCoreFxDependencies Include="libunwind" />
<CentosCoreclrAndCoreFxDependencies Include="gettext" />
<CentosCoreclrAndCoreFxDependencies Include="libcurl-devel" />
<CentosCoreclrAndCoreFxDependencies Include="openssl-devel" />
<CentosCoreclrAndCoreFxDependencies Include="zlib" />
<CentosCoreclrAndCoreFxDependencies Include="libicu-devel" />
<CentosCoreclrAndCoreFxDependencies Include="unzip" />
<CentosCoreclrAndCoreFxDependencies Include="libunwind" />
<CentosCoreclrAndCoreFxDependencies Include="gettext" />
<CentosCoreclrAndCoreFxDependencies Include="libcurl-devel" />
<CentosCoreclrAndCoreFxDependencies Include="openssl-devel" />
<CentosCoreclrAndCoreFxDependencies Include="zlib" />
<CentosCoreclrAndCoreFxDependencies Include="libicu-devel" />
</ItemGroup>
</Project>

View file

@ -1,206 +0,0 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Microsoft.DotNet.Cli.Build.Framework
{
public static class ArgumentEscaper
{
/// <summary>
/// Undo the processing which took place to create string[] args in Main,
/// so that the next process will receive the same string[] args
///
/// See here for more info:
/// http://blogs.msdn.com/b/twistylittlepassagesallalike/archive/2011/04/23/everyone-quotes-arguments-the-wrong-way.aspx
/// </summary>
/// <param name="args"></param>
/// <returns></returns>
public static string EscapeAndConcatenateArgArrayForProcessStart(IEnumerable<string> args)
{
return string.Join(" ", EscapeArgArray(args));
}
/// <summary>
/// Undo the processing which took place to create string[] args in Main,
/// so that the next process will receive the same string[] args
///
/// See here for more info:
/// http://blogs.msdn.com/b/twistylittlepassagesallalike/archive/2011/04/23/everyone-quotes-arguments-the-wrong-way.aspx
/// </summary>
/// <param name="args"></param>
/// <returns></returns>
public static string EscapeAndConcatenateArgArrayForCmdProcessStart(IEnumerable<string> args)
{
return string.Join(" ", EscapeArgArrayForCmd(args));
}
/// <summary>
/// Undo the processing which took place to create string[] args in Main,
/// so that the next process will receive the same string[] args
///
/// See here for more info:
/// http://blogs.msdn.com/b/twistylittlepassagesallalike/archive/2011/04/23/everyone-quotes-arguments-the-wrong-way.aspx
/// </summary>
/// <param name="args"></param>
/// <returns></returns>
private static IEnumerable<string> EscapeArgArray(IEnumerable<string> args)
{
var escapedArgs = new List<string>();
foreach (var arg in args)
{
escapedArgs.Add(EscapeArg(arg));
}
return escapedArgs;
}
/// <summary>
/// This prefixes every character with the '^' character to force cmd to
/// interpret the argument string literally. An alternative option would
/// be to do this only for cmd metacharacters.
///
/// See here for more info:
/// http://blogs.msdn.com/b/twistylittlepassagesallalike/archive/2011/04/23/everyone-quotes-arguments-the-wrong-way.aspx
/// </summary>
/// <param name="args"></param>
/// <returns></returns>
private static IEnumerable<string> EscapeArgArrayForCmd(IEnumerable<string> arguments)
{
var escapedArgs = new List<string>();
foreach (var arg in arguments)
{
escapedArgs.Add(EscapeArgForCmd(arg));
}
return escapedArgs;
}
private static string EscapeArg(string arg)
{
var sb = new StringBuilder();
var quoted = ShouldSurroundWithQuotes(arg);
if (quoted) sb.Append("\"");
for (int i = 0; i < arg.Length; ++i)
{
var backslashCount = 0;
// Consume All Backslashes
while (i < arg.Length && arg[i] == '\\')
{
backslashCount++;
i++;
}
// Escape any backslashes at the end of the arg
// This ensures the outside quote is interpreted as
// an argument delimiter
if (i == arg.Length)
{
sb.Append('\\', 2 * backslashCount);
}
// Escape any preceding backslashes and the quote
else if (arg[i] == '"')
{
sb.Append('\\', (2 * backslashCount) + 1);
sb.Append('"');
}
// Output any consumed backslashes and the character
else
{
sb.Append('\\', backslashCount);
sb.Append(arg[i]);
}
}
if (quoted) sb.Append("\"");
return sb.ToString();
}
/// <summary>
/// Prepare as single argument to
/// roundtrip properly through cmd.
///
/// This prefixes every character with the '^' character to force cmd to
/// interpret the argument string literally. An alternative option would
/// be to do this only for cmd metacharacters.
///
/// See here for more info:
/// http://blogs.msdn.com/b/twistylittlepassagesallalike/archive/2011/04/23/everyone-quotes-arguments-the-wrong-way.aspx
/// </summary>
/// <param name="args"></param>
/// <returns></returns>
private static string EscapeArgForCmd(string argument)
{
var sb = new StringBuilder();
var quoted = ShouldSurroundWithQuotes(argument);
if (quoted) sb.Append("^\"");
foreach (var character in argument)
{
if (character == '"')
{
sb.Append('^');
sb.Append('"');
sb.Append('^');
sb.Append(character);
}
else
{
sb.Append("^");
sb.Append(character);
}
}
if (quoted) sb.Append("^\"");
return sb.ToString();
}
/// <summary>
/// Prepare as single argument to
/// roundtrip properly through cmd.
///
/// This prefixes every character with the '^' character to force cmd to
/// interpret the argument string literally. An alternative option would
/// be to do this only for cmd metacharacters.
///
/// See here for more info:
/// http://blogs.msdn.com/b/twistylittlepassagesallalike/archive/2011/04/23/everyone-quotes-arguments-the-wrong-way.aspx
/// </summary>
/// <param name="args"></param>
/// <returns></returns>
internal static bool ShouldSurroundWithQuotes(string argument)
{
// Don't quote already quoted strings
if (argument.StartsWith("\"", StringComparison.Ordinal) &&
argument.EndsWith("\"", StringComparison.Ordinal))
{
return false;
}
// Only quote if whitespace exists in the string
if (argument.Contains(" ") || argument.Contains("\t") || argument.Contains("\n"))
{
return true;
}
return true;
}
}
}

View file

@ -1,46 +0,0 @@
using System.Collections.Generic;
namespace Microsoft.DotNet.Cli.Build.Framework
{
public static class BuildHelpers
{
public static int ExecInSilent(string workingDirectory, string command, params string[] args) => ExecInSilent(workingDirectory, command, (IEnumerable<string>)args);
public static int ExecInSilent(string workingDirectory, string command, IEnumerable<string> args) => ExecCore(command, args, workingDirectory, silent: true, env: null);
public static int ExecIn(string workingDirectory, string command, params string[] args) => ExecIn(workingDirectory, command, (IEnumerable<string>)args);
public static int ExecIn(string workingDirectory, string command, IEnumerable<string> args) => ExecCore(command, args, workingDirectory, silent: false, env: null);
public static int ExecSilent(string command, params string[] args) => ExecSilent(command, (IEnumerable<string>)args);
public static int ExecSilent(string command, IEnumerable<string> args) => ExecSilent(command, args, env: null);
public static int ExecSilent(string command, IEnumerable<string> args, IDictionary<string, string> env) => ExecCore(command, args, workingDirectory: null, silent: true, env: env);
public static int Exec(string command, params string[] args) => Exec(command, (IEnumerable<string>)args);
public static int Exec(string command, IEnumerable<string> args) => ExecCore(command, args, workingDirectory: null, silent: false, env: null);
public static Command Cmd(string command, params string[] args) => Cmd(command, (IEnumerable<string>)args);
public static Command Cmd(string command, IEnumerable<string> args)
{
return Command.Create(command, args);
}
internal static int ExecCore(string command, IEnumerable<string> args, string workingDirectory, bool silent, IDictionary<string, string> env)
{
var cmd = Cmd(command, args);
if (!string.IsNullOrEmpty(workingDirectory))
{
cmd.WorkingDirectory(workingDirectory);
}
if (silent)
{
cmd.CaptureStdErr().CaptureStdOut();
}
var result = cmd.Environment(env).Execute();
result.EnsureSuccessful();
return result.ExitCode;
}
}
}

View file

@ -1,331 +0,0 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace Microsoft.DotNet.Cli.Build.Framework
{
public class Command
{
private Process _process;
private StringWriter _stdOutCapture;
private StringWriter _stdErrCapture;
private Action<string> _stdOutForward;
private Action<string> _stdErrForward;
private Action<string> _stdOutHandler;
private Action<string> _stdErrHandler;
private bool _running = false;
private bool _quietBuildReporter = false;
private Command(string executable, string args)
{
// Set the things we need
var psi = new ProcessStartInfo()
{
FileName = executable,
Arguments = args
};
_process = new Process()
{
StartInfo = psi
};
}
public static Command Create(string executable, params string[] args)
{
return Create(executable, ArgumentEscaper.EscapeAndConcatenateArgArrayForProcessStart(args));
}
public static Command Create(string executable, IEnumerable<string> args)
{
return Create(executable, ArgumentEscaper.EscapeAndConcatenateArgArrayForProcessStart(args));
}
public static Command Create(string executable, string args)
{
ResolveExecutablePath(ref executable, ref args);
return new Command(executable, args);
}
private static void ResolveExecutablePath(ref string executable, ref string args)
{
foreach (string suffix in Constants.RunnableSuffixes)
{
var fullExecutable = Path.GetFullPath(Path.Combine(
AppContext.BaseDirectory, executable + suffix));
if (File.Exists(fullExecutable))
{
executable = fullExecutable;
// In priority order we've found the best runnable extension, so break.
break;
}
}
// On Windows, we want to avoid using "cmd" if possible (it mangles the colors, and a bunch of other things)
// So, do a quick path search to see if we can just directly invoke it
var useCmd = ShouldUseCmd(executable);
if (useCmd)
{
var comSpec = System.Environment.GetEnvironmentVariable("ComSpec");
// cmd doesn't like "foo.exe ", so we need to ensure that if
// args is empty, we just run "foo.exe"
if (!string.IsNullOrEmpty(args))
{
executable = (executable + " " + args).Replace("\"", "\\\"");
}
args = $"/C \"{executable}\"";
executable = comSpec;
}
}
private static bool ShouldUseCmd(string executable)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
var extension = Path.GetExtension(executable);
if (!string.IsNullOrEmpty(extension))
{
return !string.Equals(extension, ".exe", StringComparison.Ordinal);
}
else if (executable.Contains(Path.DirectorySeparatorChar))
{
// It's a relative path without an extension
if (File.Exists(executable + ".exe"))
{
// It refers to an exe!
return false;
}
}
else
{
// Search the path to see if we can find it
foreach (var path in System.Environment.GetEnvironmentVariable("PATH").Split(Path.PathSeparator))
{
var candidate = Path.Combine(path, executable + ".exe");
if (File.Exists(candidate))
{
// We found an exe!
return false;
}
}
}
// It's a non-exe :(
return true;
}
// Non-windows never uses cmd
return false;
}
public Command Environment(IDictionary<string, string> env)
{
if (env == null)
{
return this;
}
foreach (var item in env)
{
_process.StartInfo.Environment[item.Key] = item.Value;
}
return this;
}
public Command Environment(string key, string value)
{
_process.StartInfo.Environment[key] = value;
return this;
}
public Command QuietBuildReporter()
{
_quietBuildReporter = true;
return this;
}
public CommandResult Execute()
{
ThrowIfRunning();
_running = true;
if (_process.StartInfo.RedirectStandardOutput)
{
_process.OutputDataReceived += (sender, args) =>
{
ProcessData(args.Data, _stdOutCapture, _stdOutForward, _stdOutHandler);
};
}
if (_process.StartInfo.RedirectStandardError)
{
_process.ErrorDataReceived += (sender, args) =>
{
ProcessData(args.Data, _stdErrCapture, _stdErrForward, _stdErrHandler);
};
}
_process.EnableRaisingEvents = true;
var sw = Stopwatch.StartNew();
ReportExecBegin();
_process.Start();
if (_process.StartInfo.RedirectStandardOutput)
{
_process.BeginOutputReadLine();
}
if (_process.StartInfo.RedirectStandardError)
{
_process.BeginErrorReadLine();
}
_process.WaitForExit();
var exitCode = _process.ExitCode;
ReportExecEnd(exitCode);
return new CommandResult(
_process.StartInfo,
exitCode,
_stdOutCapture?.GetStringBuilder()?.ToString(),
_stdErrCapture?.GetStringBuilder()?.ToString());
}
public Command WorkingDirectory(string projectDirectory)
{
_process.StartInfo.WorkingDirectory = projectDirectory;
return this;
}
public Command EnvironmentVariable(string name, string value)
{
_process.StartInfo.Environment[name] = value;
return this;
}
public Command CaptureStdOut()
{
ThrowIfRunning();
_process.StartInfo.RedirectStandardOutput = true;
_stdOutCapture = new StringWriter();
return this;
}
public Command CaptureStdErr()
{
ThrowIfRunning();
_process.StartInfo.RedirectStandardError = true;
_stdErrCapture = new StringWriter();
return this;
}
public Command OnOutputLine(Action<string> handler)
{
ThrowIfRunning();
_process.StartInfo.RedirectStandardOutput = true;
if (_stdOutHandler != null)
{
throw new InvalidOperationException("Already handling stdout!");
}
_stdOutHandler = handler;
return this;
}
public Command OnErrorLine(Action<string> handler)
{
ThrowIfRunning();
_process.StartInfo.RedirectStandardError = true;
if (_stdErrHandler != null)
{
throw new InvalidOperationException("Already handling stderr!");
}
_stdErrHandler = handler;
return this;
}
private string FormatProcessInfo(ProcessStartInfo info, bool includeWorkingDirectory)
{
string prefix = includeWorkingDirectory ?
$"{info.WorkingDirectory}> {info.FileName}" :
info.FileName;
if (string.IsNullOrWhiteSpace(info.Arguments))
{
return prefix;
}
return prefix + " " + info.Arguments;
}
private void ReportExecBegin()
{
if (!_quietBuildReporter)
{
Console.WriteLine($"[> EXEC] {FormatProcessInfo(_process.StartInfo, includeWorkingDirectory: false)}");
}
}
private void ReportExecEnd(int exitCode)
{
if (!_quietBuildReporter)
{
bool success = exitCode == 0;
var message = $"{FormatProcessInfo(_process.StartInfo, includeWorkingDirectory: !success)} exited with {exitCode}";
Console.WriteLine("[< EXEC] {message}");
}
}
private void ThrowIfRunning([CallerMemberName] string memberName = null)
{
if (_running)
{
throw new InvalidOperationException($"Unable to invoke {memberName} after the command has been run");
}
}
private void ProcessData(string data, StringWriter capture, Action<string> forward, Action<string> handler)
{
if (data == null)
{
return;
}
if (capture != null)
{
capture.WriteLine(data);
}
if (forward != null)
{
forward(data);
}
if (handler != null)
{
handler(data);
}
}
}
}

View file

@ -1,50 +0,0 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.Text;
using System.Diagnostics;
namespace Microsoft.DotNet.Cli.Build.Framework
{
public struct CommandResult
{
public static readonly CommandResult Empty = new CommandResult();
public ProcessStartInfo StartInfo { get; }
public int ExitCode { get; }
public string StdOut { get; }
public string StdErr { get; }
public CommandResult(ProcessStartInfo startInfo, int exitCode, string stdOut, string stdErr)
{
StartInfo = startInfo;
ExitCode = exitCode;
StdOut = stdOut;
StdErr = stdErr;
}
public void EnsureSuccessful(bool suppressOutput = false)
{
if(ExitCode != 0)
{
StringBuilder message = new StringBuilder($"Command failed with exit code {ExitCode}: {StartInfo.FileName} {StartInfo.Arguments}");
if (!suppressOutput)
{
if (!string.IsNullOrEmpty(StdOut))
{
message.AppendLine($"{Environment.NewLine}Standard Output:{Environment.NewLine}{StdOut}");
}
if (!string.IsNullOrEmpty(StdErr))
{
message.AppendLine($"{Environment.NewLine}Standard Error:{Environment.NewLine}{StdErr}");
}
}
throw new BuildFailureException(message.ToString());
}
}
}
}

View file

@ -9,15 +9,5 @@ namespace Microsoft.DotNet.Cli.Build.Framework
{
//public static readonly string ProjectFileName = "project.json";
public static readonly string ExeSuffix = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".exe" : string.Empty;
// Priority order of runnable suffixes to look for and run
public static readonly string[] RunnableSuffixes = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
? new string[] { ".exe", ".cmd", ".bat" }
: new string[] { string.Empty };
public static readonly string DynamicLibPrefix = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "" : "lib";
public static readonly string DynamicLibSuffix = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".dll" :
RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? ".dylib" : ".so";
}
}

View file

@ -0,0 +1,65 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using System;
using System.IO;
using System.Reflection.PortableExecutable;
using System.Collections.Generic;
namespace Microsoft.DotNet.Cli.Build
{
public class AddMetadataIsPE : Task
{
[Required]
public ITaskItem[] Items { get; set; }
[Output]
public ITaskItem[] ResultItems { get; set; }
public override bool Execute()
{
var resultItemsList = new List<ITaskItem>();
foreach (var item in Items)
{
var resultItem = new TaskItem(item);
item.CopyMetadataTo(resultItem);
if (File.Exists(resultItem.GetMetadata("FullPath")) &&
HasMetadata(resultItem.GetMetadata("FullPath")))
{
resultItem.SetMetadata("IsPE", "True");
}
else
{
resultItem.SetMetadata("IsPE", "False");
}
resultItemsList.Add(resultItem);
}
ResultItems = resultItemsList.ToArray();
return true;
}
private static bool HasMetadata(string pathToFile)
{
try
{
using (var inStream = File.OpenRead(pathToFile))
{
using (var peReader = new PEReader(inStream))
{
return peReader.HasMetadata;
}
}
}
catch (BadImageFormatException) { }
return false;
}
}
}

View file

@ -4,8 +4,6 @@
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
namespace Microsoft.DotNet.Cli.Build
{
public class ChangeEntryPointLibraryName : Task

View file

@ -0,0 +1,73 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
namespace Microsoft.DotNet.Cli.Build
{
public class Chmod : ToolTask
{
[Required]
public string File { get; set; }
[Required]
public string Mode { get; set; }
public bool Recursive { get; set; }
protected override bool ValidateParameters()
{
base.ValidateParameters();
if (!System.IO.File.Exists(File))
{
Log.LogError($"File '{File} does not exist.");
return false;
}
return true;
}
protected override string ToolName
{
get { return "chmod"; }
}
protected override MessageImportance StandardOutputLoggingImportance
{
get { return MessageImportance.High; } // or else the output doesn't get logged by default
}
protected override string GenerateFullPathToTool()
{
return "chmod";
}
protected override string GenerateCommandLineCommands()
{
return $"{GetRecursive()} {GetMode()} {GetFilePath()}";
}
private string GetFilePath()
{
return File;
}
private string GetMode()
{
return Mode;
}
private string GetRecursive()
{
if(Recursive)
{
return "--recursive";
}
return null;
}
}
}

View file

@ -1,32 +0,0 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
namespace Microsoft.DotNet.Cli.Build
{
public class CleanPublishOutput : Task
{
[Required]
public string Path { get; set; }
[Required]
public string Name { get; set; }
[Required]
public bool DeleteRuntimeConfigJson { get; set; }
[Required]
public bool DeleteDepsJson { get; set; }
public override bool Execute()
{
PublishMutationUtilties.CleanPublishOutput(Path, Name, DeleteRuntimeConfigJson, DeleteDepsJson);
return true;
}
}
}

View file

@ -1,16 +0,0 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
namespace Microsoft.DotNet.Cli.Build
{
public class CliDependencyVersions
{
public static readonly string SharedFrameworkVersion = "1.0.0";
public static readonly string SharedHostVersion = "1.0.1";
public static readonly string HostFxrVersion = "1.0.1";
public static readonly string SharedFrameworkChannel = "preview";
public static readonly string SharedHostChannel = "preview";
public static readonly string HostFxrChannel = "preview";
}
}

View file

@ -0,0 +1,134 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.IO;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
namespace Microsoft.DotNet.Build.Tasks
{
public sealed class Crossgen : ToolTask
{
[Required]
public string SourceAssembly { get;set; }
[Required]
public string DestinationPath { get; set; }
[Required]
public string JITPath { get; set; }
public string CrossgenPath { get; set; }
public bool ReadyToRun { get; set; }
public ITaskItem[] PlatformAssemblyPaths { get; set; }
private string TempOutputPath { get; set; }
protected override bool ValidateParameters()
{
base.ValidateParameters();
if (!File.Exists(SourceAssembly))
{
Log.LogError($"SourceAssembly '{SourceAssembly}' does not exist.");
return false;
}
return true;
}
public override bool Execute()
{
TempOutputPath = Path.GetTempFileName();
var toolResult = base.Execute();
if (toolResult)
{
File.Copy(TempOutputPath, DestinationPath, overwrite: true);
}
if (File.Exists(TempOutputPath))
{
File.Delete(TempOutputPath);
}
return toolResult;
}
protected override string ToolName
{
get { return "crossgen"; }
}
protected override MessageImportance StandardOutputLoggingImportance
{
get { return MessageImportance.High; } // or else the output doesn't get logged by default
}
protected override string GenerateFullPathToTool()
{
if (CrossgenPath != null)
{
return CrossgenPath;
}
return "crossgen";
}
protected override string GenerateCommandLineCommands()
{
return $"{GetReadyToRun()} {GetInPath()} {GetOutPath()} {GetPlatformAssemblyPaths()} {GetJitPath()}";
}
private string GetReadyToRun()
{
if (ReadyToRun)
{
return "-readytorun";
}
return null;
}
private string GetInPath()
{
return $"-in {SourceAssembly}";
}
private string GetOutPath()
{
return $"-out {TempOutputPath}";
}
private string GetPlatformAssemblyPaths()
{
var platformAssemblyPaths = String.Empty;
if (PlatformAssemblyPaths != null)
{
foreach (var excludeTaskItem in PlatformAssemblyPaths)
{
platformAssemblyPaths += $"{excludeTaskItem.ItemSpec}{Path.PathSeparator}";
}
}
return $" -platform_assemblies_paths {platformAssemblyPaths.Trim(':')}";
}
private string GetJitPath()
{
return $"-JITPath {JITPath}";
}
protected override void LogToolCommand(string message)
{
base.LogToolCommand($"{base.GetWorkingDirectory()}> {message}");
}
}
}

View file

@ -1,34 +0,0 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
namespace Microsoft.DotNet.Cli.Build
{
public class CrossgenDirectory : Task
{
[Required]
public string CoreCLRVersion { get; set; }
[Required]
public string JitVersion { get; set; }
[Required]
public string SharedFrameworkNameVersionPath { get; set; }
[Required]
public string SdkOutputDirectory { get; set; }
public override bool Execute()
{
var crossgenUtil = new Crossgen(CoreCLRVersion, JitVersion);
crossgenUtil.CrossgenDirectory(SharedFrameworkNameVersionPath, SdkOutputDirectory);
return true;
}
}
}

View file

@ -0,0 +1,18 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
namespace Microsoft.DotNet.Cli.Build
{
public class DotNetNew : DotNetTool
{
protected override string Command
{
get { return "new"; }
}
protected override string Args
{
get { return $""; }
}
}
}

View file

@ -0,0 +1,102 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
namespace Microsoft.DotNet.Cli.Build
{
public class DotNetPublish : DotNetTool
{
protected override string Command
{
get { return "publish"; }
}
protected override string Args
{
get { return $"{GetProjectPath()} {GetConfiguration()} {GetFramework()} {GetNativeSubdirectory()} {GetBuildBasePath()} {GetOutput()} {GetVersionSuffix()}"; }
}
public string BuildBasePath { get; set; }
public string Configuration { get; set; }
public string Framework { get; set; }
public bool NativeSubDirectory { get; set; }
public string Output { get; set; }
public string ProjectPath { get; set; }
public string VersionSuffix { get; set; }
private string GetBuildBasePath()
{
if (!string.IsNullOrEmpty(BuildBasePath))
{
return $"--build-base-path {BuildBasePath}";
}
return null;
}
private string GetConfiguration()
{
if (!string.IsNullOrEmpty(Configuration))
{
return $"--configuration {Configuration}";
}
return null;
}
private string GetFramework()
{
if (!string.IsNullOrEmpty(Framework))
{
return $"--framework {Framework}";
}
return null;
}
private string GetNativeSubdirectory()
{
if (NativeSubDirectory)
{
return $"--native-subdirectory";
}
return null;
}
private string GetOutput()
{
if (!string.IsNullOrEmpty(Output))
{
return $"--output {Output}";
}
return null;
}
private string GetProjectPath()
{
if (!string.IsNullOrEmpty(ProjectPath))
{
return $"{ProjectPath}";
}
return null;
}
private string GetVersionSuffix()
{
if (!string.IsNullOrEmpty(VersionSuffix))
{
return $"--version-suffix {VersionSuffix}";
}
return null;
}
}
}

View file

@ -12,11 +12,13 @@ namespace Microsoft.DotNet.Cli.Build
protected override string Args
{
get { return $"{GetVerbosity()} {GetFallbackSource()}"; }
get { return $"{GetVerbosity()} {GetFallbackSource()} {GetPackages()}"; }
}
public string FallbackSource { get; set; }
public string Packages { get; set; }
public string Verbosity { get; set; }
private string GetFallbackSource()
@ -29,6 +31,16 @@ namespace Microsoft.DotNet.Cli.Build
return null;
}
private string GetPackages()
{
if (!string.IsNullOrEmpty(Packages))
{
return $"--packages {Packages}";
}
return null;
}
private string GetVerbosity()
{
if (!string.IsNullOrEmpty(Verbosity))

View file

@ -4,6 +4,8 @@
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Microsoft.DotNet.Cli.Build.Framework;
namespace Microsoft.DotNet.Cli.Build
{
public abstract class DotNetTool : ToolTask
@ -20,7 +22,7 @@ namespace Microsoft.DotNet.Cli.Build
protected override string ToolName
{
get { return HostArtifactNames.DotnetHostBaseName; }
get { return $"dotnet{Constants.ExeSuffix}"; }
}
protected override MessageImportance StandardOutputLoggingImportance

View file

@ -1,38 +0,0 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System.IO.Compression;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Microsoft.DotNet.Cli.Build.Framework;
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
namespace Microsoft.DotNet.Cli.Build
{
public class ExtractArchive : Task
{
[Required]
public string InputFile { get; set; }
[Required]
public string DestinationDirectory { get; set; }
public override bool Execute()
{
FS.Mkdirp(DestinationDirectory);
Log.LogMessage($"Extracting Archive '{InputFile}' to '{DestinationDirectory}'");
if (CurrentPlatform.IsWindows)
{
ZipFile.ExtractToDirectory(InputFile, DestinationDirectory);
}
else
{
Exec("tar", "xf", InputFile, "-C", DestinationDirectory);
}
return true;
}
}
}

View file

@ -1,23 +0,0 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
namespace Microsoft.DotNet.Cli.Build
{
public class FixModeFlags : Task
{
[Required]
public string Dir { get; set; }
public override bool Execute()
{
FS.FixModeFlags(Dir);
return true;
}
}
}

View file

@ -6,7 +6,7 @@ using Microsoft.Build.Utilities;
namespace Microsoft.DotNet.Cli.Build
{
public class GenerateBuildVersionInfo : Task
public class GenerateBuildVersionInfo : ToolTask
{
[Required]
public string RepoRoot { get; set; }
@ -20,9 +20,6 @@ namespace Microsoft.DotNet.Cli.Build
[Output]
public int VersionPatch { get; set; }
[Output]
public string CommitHash { get; set; }
[Output]
public string CommitCount { get; set; }
@ -50,12 +47,13 @@ namespace Microsoft.DotNet.Cli.Build
[Output]
public string BranchName { get; set; }
private int _commitCount;
public override bool Execute()
{
var branchInfo = new BranchInfo(RepoRoot);
base.Execute();
var commitCount = GitUtils.GetCommitCount();
var commitHash = GitUtils.GetCommitHash();
var branchInfo = new BranchInfo(RepoRoot);
var buildVersion = new BuildVersion()
{
@ -63,13 +61,12 @@ namespace Microsoft.DotNet.Cli.Build
Minor = int.Parse(branchInfo.Entries["MINOR_VERSION"]),
Patch = int.Parse(branchInfo.Entries["PATCH_VERSION"]),
ReleaseSuffix = branchInfo.Entries["RELEASE_SUFFIX"],
CommitCount = commitCount
CommitCount = _commitCount
};
VersionMajor = buildVersion.Major;
VersionMinor = buildVersion.Minor;
VersionPatch = buildVersion.Patch;
CommitHash = commitHash;
CommitCount = buildVersion.CommitCountString;
ReleaseSuffix = buildVersion.ReleaseSuffix;
VersionSuffix = buildVersion.VersionSuffix;
@ -82,5 +79,30 @@ namespace Microsoft.DotNet.Cli.Build
return true;
}
protected override string ToolName
{
get { return "git"; }
}
protected override MessageImportance StandardOutputLoggingImportance
{
get { return MessageImportance.High; } // or else the output doesn't get logged by default
}
protected override string GenerateFullPathToTool()
{
return "git";
}
protected override string GenerateCommandLineCommands()
{
return $"rev-list --count HEAD";
}
protected override void LogEventsFromTextOutput(string line, MessageImportance importance)
{
_commitCount = int.Parse(line);
}
}
}

View file

@ -0,0 +1,42 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
namespace Microsoft.DotNet.Cli.Build
{
public class GetCommitHash : ToolTask
{
[Required]
public string RepoRoot { get; set; }
[Output]
public string CommitHash { get; set; }
protected override string ToolName
{
get { return "git"; }
}
protected override MessageImportance StandardOutputLoggingImportance
{
get { return MessageImportance.High; } // or else the output doesn't get logged by default
}
protected override string GenerateFullPathToTool()
{
return "git";
}
protected override string GenerateCommandLineCommands()
{
return $"rev-parse HEAD";
}
protected override void LogEventsFromTextOutput(string line, MessageImportance importance)
{
CommitHash = line;
}
}
}

View file

@ -0,0 +1,112 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using System;
using System.IO;
using System.IO.Compression;
namespace Microsoft.DotNet.Build.Tasks
{
public sealed class TarGzFileExtractToDirectory : ToolTask
{
/// <summary>
/// The path to the archive to extract.
/// </summary>
[Required]
public string SourceArchive { get; set; }
/// <summary>
/// The path of the directory to which the archive should be extracted.
/// </summary>
[Required]
public string DestinationDirectory { get; set; }
/// <summary>
/// Indicates if the destination directory should be cleaned if it already exists.
/// </summary>
public bool OverwriteDestination { get; set; }
protected override bool ValidateParameters()
{
base.ValidateParameters();
var retVal = true;
if (Directory.Exists(DestinationDirectory))
{
if (OverwriteDestination == true)
{
Log.LogMessage(MessageImportance.Low, "'{0}' already exists, trying to delete before unzipping...", DestinationDirectory);
Directory.Delete(DestinationDirectory, recursive: true);
}
else
{
Log.LogWarning("'{0}' already exists. Did you forget to set '{1}' to true?", DestinationDirectory, nameof(OverwriteDestination));
retVal = false;
}
}
if (!File.Exists(SourceArchive))
{
Log.LogError($"SourceArchive '{SourceArchive} does not exist.");
retVal = false;
}
if (retVal)
{
Log.LogMessage($"Creating Directory {DestinationDirectory}");
Directory.CreateDirectory(DestinationDirectory);
}
return retVal;
}
public override bool Execute()
{
bool retVal = base.Execute();
if (!retVal)
{
Log.LogMessage($"Deleting Directory {DestinationDirectory}");
Directory.Delete(DestinationDirectory);
}
return retVal;
}
protected override string ToolName
{
get { return "tar"; }
}
protected override MessageImportance StandardOutputLoggingImportance
{
get { return MessageImportance.High; } // or else the output doesn't get logged by default
}
protected override string GenerateFullPathToTool()
{
return "tar";
}
protected override string GenerateCommandLineCommands()
{
return $"xf {GetSourceArchive()} -C {GetDestinationDirectory()}";
}
private string GetSourceArchive()
{
return SourceArchive;
}
private string GetDestinationDirectory()
{
return DestinationDirectory;
}
}
}

View file

@ -1,13 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Microsoft.DotNet.Cli.Build
{
public class DependencyVersions
{
public static readonly string CoreCLRVersion = "1.0.2";
public static readonly string JitVersion = "1.0.2";
}
}

View file

@ -1,15 +0,0 @@
using Microsoft.DotNet.Cli.Build.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Microsoft.DotNet.Cli.Build
{
public class HostArtifactNames
{
public static string DotnetHostBaseName => $"dotnet{Constants.ExeSuffix}";
public static string DotnetHostFxrBaseName => $"{Constants.DynamicLibPrefix}hostfxr{Constants.DynamicLibSuffix}";
public static string HostPolicyBaseName => $"{Constants.DynamicLibPrefix}hostpolicy{Constants.DynamicLibSuffix}";
}
}

View file

@ -1,55 +0,0 @@
using System;
using System.IO;
using System.Net.Http;
using System.Text;
using Microsoft.DotNet.Cli.Build.Framework;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
namespace Microsoft.DotNet.Cli.Build
{
public class DebRepoPublisher
{
private const string _debianRevisionNumber = "1";
private string _repoID;
private string _uploadJsonDirectory;
public DebRepoPublisher(string uploadJsonDirectory)
{
_uploadJsonDirectory = uploadJsonDirectory;
_repoID = Environment.GetEnvironmentVariable("REPO_ID");
}
public void PublishDebFileToDebianRepo(string packageName, string packageVersion, string uploadUrl)
{
var uploadJson = GenerateUploadJsonFile(packageName, packageVersion, uploadUrl);
Cmd(Path.Combine(Dirs.RepoRoot, "scripts", "publish", "repoapi_client.sh"), "-addpkg", uploadJson)
.Execute()
.EnsureSuccessful();
}
private string GenerateUploadJsonFile(string packageName, string packageVersion, string uploadUrl)
{
var uploadJson = Path.Combine(_uploadJsonDirectory, "package_upload.json");
File.Delete(uploadJson);
using (var fileStream = File.Create(uploadJson))
{
using (StreamWriter sw = new StreamWriter(fileStream))
{
sw.WriteLine("{");
sw.WriteLine($" \"name\":\"{packageName}\",");
sw.WriteLine($" \"version\":\"{packageVersion}-{_debianRevisionNumber}\",");
sw.WriteLine($" \"repositoryId\":\"{_repoID}\",");
sw.WriteLine($" \"sourceUrl\":\"{uploadUrl}\"");
sw.WriteLine("}");
}
}
return uploadJson;
}
}
}

View file

@ -8,8 +8,6 @@ using Microsoft.DotNet.Cli.Build.Framework;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
namespace Microsoft.DotNet.Cli.Build
{
public class BranchInfo

View file

@ -1,209 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.DotNet.Cli.Build.Framework;
using Microsoft.DotNet.InternalAbstractions;
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
namespace Microsoft.DotNet.Cli.Build
{
public class Crossgen
{
private string _coreClrVersion;
private string _jitVersion;
private string _crossGenPath;
private static readonly string[] s_excludedLibraries =
{
"mscorlib.dll",
"mscorlib.ni.dll",
"System.Private.CoreLib.dll",
"System.Private.CoreLib.ni.dll"
};
// This is not always correct. The version of crossgen we need to pick up is whatever one was restored as part
// of the Microsoft.NETCore.Runtime.CoreCLR package that is part of the shared library. For now, the version hardcoded
// in CompileTargets and the one in the shared library project.json match and are updated in lock step, but long term
// we need to be able to look at the project.lock.json file and figure out what version of Microsoft.NETCore.Runtime.CoreCLR
// was used, and then select that version.
public Crossgen(string coreClrVersion, string jitVersion)
{
_coreClrVersion = coreClrVersion;
_jitVersion = jitVersion;
_crossGenPath = GetCrossgenPathForVersion();
}
private string GetCrossgenPathForVersion()
{
var crossgenPackagePath = GetCrossGenPackagePathForVersion();
if (crossgenPackagePath == null)
{
return null;
}
return Path.Combine(
crossgenPackagePath,
"tools",
$"crossgen{Constants.ExeSuffix}");
}
private string GetLibCLRJitPathForVersion()
{
var jitRid = GetCoreCLRRid();
var jitPackagePath = GetJitPackagePathForVersion();
if (jitPackagePath == null)
{
return null;
}
return Path.Combine(
jitPackagePath,
"runtimes",
jitRid,
"native",
$"{Constants.DynamicLibPrefix}clrjit{Constants.DynamicLibSuffix}");
}
private string GetJitPackagePathForVersion()
{
string jitRid = GetCoreCLRRid();
if (jitRid == null)
{
return null;
}
string packageId = $"runtime.{jitRid}.Microsoft.NETCore.Jit";
return Path.Combine(
Dirs.NuGetPackages,
packageId,
_jitVersion);
}
private string GetCoreLibsDirForVersion()
{
string coreclrRid = GetCoreCLRRid();
if (coreclrRid == null)
{
return null;
}
string packageId = $"runtime.{coreclrRid}.Microsoft.NETCore.Runtime.CoreCLR";
return Path.Combine(
Dirs.NuGetPackages,
packageId,
_coreClrVersion,
"runtimes",
coreclrRid,
"lib",
"netstandard1.0");
}
private string GetCrossGenPackagePathForVersion()
{
string coreclrRid = GetCoreCLRRid();
if (coreclrRid == null)
{
return null;
}
string packageId = $"runtime.{coreclrRid}.Microsoft.NETCore.Runtime.CoreCLR";
return Path.Combine(
Dirs.NuGetPackages,
packageId,
_coreClrVersion);
}
private string GetCoreCLRRid()
{
string rid = null;
if (CurrentPlatform.IsWindows)
{
var arch = RuntimeEnvironment.RuntimeArchitecture;
rid = $"win7-{arch}";
}
else if (CurrentPlatform.IsOSX)
{
rid = "osx.10.10-x64";
}
else if (CurrentPlatform.IsCentOS || CurrentPlatform.IsRHEL)
{
// CentOS runtime is in the runtime.rhel.7-x64... package as are all
// versions of RHEL
rid = "rhel.7-x64";
}
else if (CurrentPlatform.IsLinux)
{
rid = RuntimeEnvironment.GetRuntimeIdentifier();
}
return rid;
}
public void CrossgenDirectory(string sharedFxPath, string pathToAssemblies)
{
// Check if we need to skip crossgen
if (string.Equals(Environment.GetEnvironmentVariable("DISABLE_CROSSGEN"), "1"))
{
var originalColor = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("Skipping crossgen for because DISABLE_CROSSGEN is set to 1");
Console.ForegroundColor = originalColor;
return;
}
// HACK
// The input directory can be a portable FAT app (example the CLI itself).
// In that case there can be RID specific managed dependencies which are not right next to the app binary (example System.Diagnostics.TraceSource).
// We need those dependencies during crossgen. For now we just pass all subdirectories of the input directory as input to crossgen.
// The right fix -
// If the assembly has deps.json then parse the json file to get all the dependencies, pass these dependencies as input to crossgen.
// else pass the current directory of assembly as input to crossgen.
var coreLibsDir = GetCoreLibsDirForVersion();
var addtionalPaths = Directory.GetDirectories(pathToAssemblies, "*", SearchOption.AllDirectories).ToList();
var paths = new List<string>() { coreLibsDir, sharedFxPath, pathToAssemblies };
paths.AddRange(addtionalPaths);
var platformAssembliesPaths = string.Join(Path.PathSeparator.ToString(), paths.Distinct());
var jitPath = GetLibCLRJitPathForVersion();
var env = new Dictionary<string, string>()
{
// disable partial ngen
{ "COMPlus_PartialNGen", "0" }
};
foreach (var file in Directory.GetFiles(pathToAssemblies))
{
string fileName = Path.GetFileName(file);
if (s_excludedLibraries.Any(lib => String.Equals(lib, fileName, StringComparison.OrdinalIgnoreCase))
|| !PEUtils.HasMetadata(file))
{
continue;
}
string tempPathName = Path.ChangeExtension(file, "readytorun");
IList<string> crossgenArgs = new List<string> {
"-readytorun", "-in", file, "-out", tempPathName,
"-platform_assemblies_paths", platformAssembliesPaths
};
crossgenArgs.Add("-JITPath");
crossgenArgs.Add(jitPath);
ExecSilent(_crossGenPath, crossgenArgs, env);
File.Copy(tempPathName, file, overwrite: true);
File.Delete(tempPathName);
}
}
}
}

View file

@ -8,43 +8,10 @@ namespace Microsoft.DotNet.Cli.Build
public static class Dirs
{
public static readonly string RepoRoot = Directory.GetCurrentDirectory();
public static readonly string DebPackagingConfig = Path.Combine(Dirs.RepoRoot, "packaging", "deb");
public static readonly string Output = Path.Combine(
RepoRoot,
"artifacts",
RuntimeEnvironment.GetRuntimeIdentifier());
public static readonly string Intermediate = Path.Combine(Output, "intermediate");
public static readonly string PackagesNoRID = Path.Combine(RepoRoot, "artifacts", "packages");
public static readonly string Packages = Path.Combine(Output, "packages");
public static readonly string Stage1 = Path.Combine(Output, "stage1");
public static readonly string Stage1Compilation = Path.Combine(Output, "stage1compilation");
public static readonly string Stage1Symbols = Path.Combine(Output, "stage1symbols");
public static readonly string Stage2 = Path.Combine(Output, "stage2");
public static readonly string Stage2Compilation = Path.Combine(Output, "stage2compilation");
public static readonly string Stage2Symbols = Path.Combine(Output, "stage2symbols");
public static readonly string CorehostLatest = Path.Combine(Output, "corehost"); // Not using Path.Combine(Output, "corehost", "latest") to keep signing working.
public static readonly string CorehostLocked = Path.Combine(Output, "corehost", "locked");
public static readonly string CorehostLocalPackages = Path.Combine(Output, "corehost");
public static readonly string CorehostDummyPackages = Path.Combine(Output, "corehostdummypackages");
public static readonly string SharedFrameworkPublish = Path.Combine(Intermediate, "sharedFrameworkPublish");
public static readonly string TestOutput = Path.Combine(Output, "tests");
public static readonly string TestArtifacts = Path.Combine(TestOutput, "artifacts");
public static readonly string TestPackages = Path.Combine(TestOutput, "packages");
public static readonly string TestPackagesBuild = Path.Combine(TestOutput, "packagesBuild");
public static readonly string OSXReferenceAssembliesPath = "/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/xbuild-frameworks";
public static readonly string UsrLocalReferenceAssembliesPath = "/usr/local/lib/mono/xbuild-frameworks";
public static readonly string UsrReferenceAssembliesPath = "/usr/lib/mono/xbuild-frameworks";
public static string NuGetPackages = Environment.GetEnvironmentVariable("NUGET_PACKAGES") ?? GetNuGetPackagesDir();
private static string GetNuGetPackagesDir()
{
return Path.Combine(Dirs.RepoRoot, ".nuget", "packages");
}
}
}

View file

@ -1,63 +0,0 @@
using System;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using Microsoft.DotNet.Cli.Build.Framework;
using Microsoft.DotNet.InternalAbstractions;
namespace Microsoft.DotNet.Cli.Build
{
public class DotNetCli
{
public static readonly DotNetCli Stage0 = new DotNetCli(GetStage0Path());
public static readonly DotNetCli Stage1 = new DotNetCli(Dirs.Stage1);
public static readonly DotNetCli Stage2 = new DotNetCli(Dirs.Stage2);
public string BinPath { get; }
public DotNetCli(string binPath)
{
BinPath = binPath;
}
public Command Exec(string command, params string[] args)
{
var newArgs = args.ToList();
newArgs.Insert(0, command);
if (EnvVars.Verbose)
{
newArgs.Insert(0, "-v");
}
return Command.Create(Path.Combine(BinPath, $"dotnet{Constants.ExeSuffix}"), newArgs);
}
public Command Restore(params string[] args) => Exec("restore", args);
public Command Build(params string[] args) => Exec("build", args);
public Command Pack(params string[] args) => Exec("pack", args);
public Command Test(params string[] args) => Exec("test", args);
public Command Publish(params string[] args) => Exec("publish", args);
public Command New(params string[] args) => Exec("new", args);
public string GetRuntimeId()
{
string info = Exec("", "--info").CaptureStdOut().Execute().StdOut;
string rid = Array.Find<string>(info.Split(Environment.NewLine.ToCharArray()), (e) => e.Contains("RID:"))?.Replace("RID:", "").Trim();
if (string.IsNullOrEmpty(rid))
{
throw new BuildFailureException("Could not find the Runtime ID from Stage0 --info or --version");
}
return rid;
}
private static string GetStage0Path()
{
return Path.Combine(Directory.GetCurrentDirectory(),
".dotnet_stage0",
RuntimeEnvironment.RuntimeArchitecture);
}
}
}

View file

@ -4,8 +4,6 @@ using System;
using Microsoft.DotNet.Cli.Build.Framework;
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
namespace Microsoft.DotNet.Cli.Build
{
public static class FS
@ -17,90 +15,5 @@ namespace Microsoft.DotNet.Cli.Build
Directory.CreateDirectory(dir);
}
}
public static void Rm(string file)
{
if(File.Exists(file))
{
File.Delete(file);
}
}
public static void Rmdir(string dir)
{
if(Directory.Exists(dir))
{
Directory.Delete(dir, recursive: true);
}
}
public static void RmFilesInDirRecursive(string dir, string filePattern)
{
var files = Directory.EnumerateFiles(dir, filePattern, SearchOption.AllDirectories);
foreach (var file in files)
{
FS.Rm(file);
}
}
public static void Chmod(string file, string mode, bool recursive = false)
{
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
if (recursive)
{
Command.Create("chmod", "-R", mode, file).Execute().EnsureSuccessful();
}
else
{
Command.Create("chmod", mode, file).Execute().EnsureSuccessful();
}
}
}
public static void ChmodAll(string searchDir, string pattern, string mode)
{
Exec("find", searchDir, "-type", "f", "-name", pattern, "-exec", "chmod", mode, "{}", ";");
}
public static void FixModeFlags(string dir)
{
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
// Managed code doesn't need 'x'
ChmodAll(dir, "*.dll", "644");
ChmodAll(dir, "*.exe", "644");
// Generally, dylibs and sos have 'x' (no idea if it's required ;))
// (No need to condition this on OS since there shouldn't be any dylibs on Linux,
// but even if they are we may as well set their mode flags :))
ChmodAll(dir, "*.dylib", "755");
ChmodAll(dir, "*.so", "755");
// Executables (those without dots) are executable :)
Exec("find", dir, "-type", "f", "!", "-name", "*.*", "-exec", "chmod", "755", "{}", ";");
}
}
public static void CopyRecursive(string sourceDirectory, string destinationDirectory, bool overwrite = false)
{
Mkdirp(destinationDirectory);
foreach(var dir in Directory.EnumerateDirectories(sourceDirectory))
{
CopyRecursive(dir, Path.Combine(destinationDirectory, Path.GetFileName(dir)), overwrite);
}
foreach(var file in Directory.EnumerateFiles(sourceDirectory))
{
var dest = Path.Combine(destinationDirectory, Path.GetFileName(file));
if (!File.Exists(dest) || overwrite)
{
// We say overwrite true, because we only get here if the file didn't exist (thus it doesn't matter) or we
// wanted to overwrite :)
File.Copy(file, dest, overwrite: true);
}
}
}
}
}

View file

@ -1,27 +0,0 @@
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
namespace Microsoft.DotNet.Cli.Build
{
public static class GitUtils
{
public static int GetCommitCount()
{
return int.Parse(ExecuteGitCommand("rev-list", "--count", "HEAD"));
}
public static string GetCommitHash()
{
return ExecuteGitCommand("rev-parse", "HEAD");
}
private static string ExecuteGitCommand(params string[] args)
{
var gitResult = Cmd("git", args)
.CaptureStdOut()
.Execute();
gitResult.EnsureSuccessful();
return gitResult.StdOut.Trim();
}
}
}

View file

@ -1,48 +0,0 @@
using System.Collections.Generic;
namespace Microsoft.DotNet.Cli.Build
{
public class HostVersion : Version
{
// ------------------------------------------HOST-VERSIONING-------------------------------------------
//
// Host versions are independent of CLI versions. Moreover, these version numbers
// are baked into the binary and is used to look up a serviced binary replacement.
//
//
// Latest hosts for production of nupkgs.
//
// Version constants without suffix
public override int Major => 1;
public override int Minor => 0;
public override int Patch => 1;
public override string ReleaseSuffix => "rc3";
public string LatestHostVersionNoSuffix => $"{Major}.{Minor}.{Patch}";
public string LatestHostFxrVersionNoSuffix => $"{Major}.{Minor}.{Patch}";
public string LatestHostPolicyVersionNoSuffix => $"{Major}.{Minor}.{Patch}";
public string LatestHostPrerelease => ReleaseSuffix;
public string LatestHostBuildMajor => $"{CommitCountString}";
public string LatestHostBuildMinor => "00";
public string LatestHostSuffix => $"{ReleaseSuffix}-{LatestHostBuildMajor}-{LatestHostBuildMinor}";
// Full versions and package information.
public string LatestHostVersion => $"{LatestHostVersionNoSuffix}-{LatestHostSuffix}";
public string LatestHostFxrVersion => $"{LatestHostFxrVersionNoSuffix}-{LatestHostSuffix}";
public string LatestHostPolicyVersion => $"{LatestHostPolicyVersionNoSuffix}-{LatestHostSuffix}";
public Dictionary<string, string> LatestHostPackages => new Dictionary<string, string>()
{
{ "Microsoft.NETCore.DotNetHost", LatestHostVersion },
{ "Microsoft.NETCore.DotNetHostResolver", LatestHostFxrVersion },
{ "Microsoft.NETCore.DotNetHostPolicy", LatestHostPolicyVersion }
};
//
// Locked muxer for consumption in CLI.
//
public bool IsLocked = false; // Set this variable to toggle muxer locking.
public string LockedHostFxrVersion => IsLocked ? "1.0.1-rc2-002468-00" : LatestHostFxrVersion;
public string LockedHostVersion => IsLocked ? "1.0.1-rc2-002468-00" : LatestHostVersion;
}
}

View file

@ -1,28 +0,0 @@
using System;
using System.IO;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace Microsoft.DotNet.Cli.Build
{
public static class JsonUtils
{
public static JObject ReadProject(string projectJsonPath)
{
using (TextReader projectFileReader = File.OpenText(projectJsonPath))
{
var projectJsonReader = new JsonTextReader(projectFileReader);
var serializer = new JsonSerializer();
return serializer.Deserialize<JObject>(projectJsonReader);
}
}
public static void WriteProject(JObject projectRoot, string projectJsonPath)
{
string projectJson = JsonConvert.SerializeObject(projectRoot, Formatting.Indented);
File.WriteAllText(projectJsonPath, projectJson + Environment.NewLine);
}
}
}

View file

@ -9,12 +9,6 @@ namespace Microsoft.DotNet.Cli.Build
{
public class Monikers
{
public const string SharedFrameworkName = "Microsoft.NETCore.App";
public const string CLISdkBrandName = "Microsoft .NET Core 1.0.0 - SDK Preview 2";
public const string SharedFxBrandName = "Microsoft .NET Core 1.0.0 - Runtime";
public const string SharedHostBrandName = "Microsoft .NET Core 1.0.0 - Host";
public const string HostFxrBrandName = "Microsoft .NET Core 1.0.0 - Host FX Resolver";
public static string GetBadgeMoniker()
{
switch (RuntimeEnvironment.GetRuntimeIdentifier())
@ -29,16 +23,6 @@ namespace Microsoft.DotNet.Cli.Build
return $"{CurrentPlatform.Current}_{CurrentArchitecture.Current}";
}
public static string GetDebianHostFxrPackageName(string hostFxrNugetVersion)
{
return $"dotnet-hostfxr-{hostFxrNugetVersion}".ToLower();
}
public static string GetDebianSharedFrameworkPackageName(string sharedFrameworkNugetVersion)
{
return $"dotnet-sharedframework-{SharedFrameworkName}-{sharedFrameworkNugetVersion}".ToLower();
}
public static string GetOSShortName()
{

View file

@ -1,27 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection.PortableExecutable;
namespace Microsoft.DotNet.Cli.Build
{
public static class PEUtils
{
public static bool HasMetadata(string pathToFile)
{
try
{
using (var inStream = File.OpenRead(pathToFile))
{
using (var peReader = new PEReader(inStream))
{
return peReader.HasMetadata;
}
}
}
catch (BadImageFormatException) { }
return false;
}
}
}

View file

@ -11,27 +11,6 @@ namespace Microsoft.DotNet.Cli.Build
{
public class PublishMutationUtilties
{
public static void CleanPublishOutput(
string path,
string name,
bool deleteRuntimeConfigJson=false,
bool deleteDepsJson=false)
{
File.Delete(Path.Combine(path, $"{name}{Constants.ExeSuffix}"));
File.Delete(Path.Combine(path, $"{name}.dll"));
File.Delete(Path.Combine(path, $"{name}.pdb"));
if (deleteRuntimeConfigJson)
{
File.Delete(Path.Combine(path, $"{name}.runtimeconfig.json"));
}
if (deleteDepsJson)
{
File.Delete(Path.Combine(path, $"{name}.deps.json"));
}
}
public static void ChangeEntryPointLibraryName(string depsFile, string newName)
{
JToken deps;

View file

@ -9,83 +9,6 @@ namespace Microsoft.DotNet.Cli.Build
{
public static class Utils
{
public static void CleanNuGetTempCache()
{
// Clean NuGet Temp Cache on Linux (seeing some issues on Linux)
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && Directory.Exists("/tmp/NuGet"))
{
Directory.Delete("/tmp/NuGet", recursive: true);
}
}
public static string GetOSName()
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return "win";
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
return "osx";
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
throw new NotImplementedException();
}
else
{
throw new PlatformNotSupportedException();
}
}
public static void DeleteDirectory(string path)
{
if (Directory.Exists(path))
{
string[] files = Directory.GetFiles(path, "*", SearchOption.AllDirectories);
foreach (string file in files)
{
File.SetAttributes(file, FileAttributes.Normal);
File.Delete(file);
}
var retry = 5;
while (retry >= 0)
{
try
{
Directory.Delete(path, true);
return;
}
catch (IOException)
{
if (retry == 0)
{
throw;
}
System.Threading.Thread.Sleep(200);
retry--;
}
}
}
}
public static void CopyDirectoryRecursively(string path, string destination, bool keepParentDir = false)
{
if (keepParentDir)
{
path = path.TrimEnd(Path.DirectorySeparatorChar);
destination = Path.Combine(destination, Path.GetFileName(path));
Directory.CreateDirectory(destination);
}
foreach (var file in Directory.GetFiles(path, "*", SearchOption.AllDirectories))
{
string destFile = file.Replace(path, destination);
Directory.CreateDirectory(Path.GetDirectoryName(destFile));
File.Copy(file, destFile, true);
}
}
public static string GetVersionFileContent(string commitHash, string version)
{
return $@"{commitHash}{Environment.NewLine}{version}{Environment.NewLine}";