Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Commit

Permalink
Add global tool support in corefx
Browse files Browse the repository at this point in the history
  • Loading branch information
ViktorHofer committed Dec 3, 2018
1 parent a9c1fc0 commit a1a67e3
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 17 deletions.
10 changes: 6 additions & 4 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,9 @@
<SourceDir>$(ProjectDir)src\</SourceDir>

<!-- CoreFx sepcific paths -->
<GlobalToolsDir>$(ProjectDir)artifacts/tools/</GlobalToolsDir>
<TestWorkingDir Condition="'$(TestWorkingDir)'==''">$(BinDir)tests/</TestWorkingDir>

<TestArchiveRoot>$(ProjectDir)artifacts/helix/</TestArchiveRoot>
<TestArchiveTestsDir>$(TestArchiveRoot)tests/</TestArchiveTestsDir>
<TestArchiveRuntimeDir>$(TestArchiveRoot)runtime/</TestArchiveRuntimeDir>

<!-- Input Directories -->
<PackagesDir>$(DotNetRestorePackagesPath)</PackagesDir>
<PackagesDir Condition="'$(PackagesDir)'=='' AND '$(NuGetPackageRoot)' != ''">$([MSBuild]::EnsureTrailingSlash('$(NuGetPackageRoot)'))</PackagesDir>
Expand All @@ -80,6 +77,8 @@
<DotNetRoot Condition="!HasTrailingSlash('$(DotNetRoot)')">$(DotNetRoot)\</DotNetRoot>
<DotnetCliPath Condition="'$(DotnetCliPath)'==''">$(DotNetRoot)</DotnetCliPath>
<ToolHostCmd Condition="'$(ToolHostCmd)'==''">"$(DotNetRoot)dotnet"</ToolHostCmd>
<DotNetCmd>$(DotNetRoot)dotnet</DotNetCmd>
<DotNetCmd Condition="'$(OS)' == 'Windows_NT'">$(DotNetCmd).exe</DotNetCmd>
</PropertyGroup>

<!-- Choose .targets files that come from Arcade rather than from buildtools -->
Expand Down Expand Up @@ -373,6 +372,9 @@
<RefPath Condition="$(TargetGroup.EndsWith('aot'))">$(RefRootPath)$(TargetGroup.TrimEnd('t').TrimEnd('o').TrimEnd('a'))/</RefPath>
<NetStandardRefPath>$(RefRootPath)netstandard/</NetStandardRefPath>
<NetFxRefPath>$(RefRootPath)netfx/</NetFxRefPath>
<TestArchiveRoot>$(ProjectDir)artifacts/helix/</TestArchiveRoot>
<TestArchiveTestsDir>$(TestArchiveRoot)tests/</TestArchiveTestsDir>
<TestArchiveRuntimeDir>$(TestArchiveRoot)runtime/$(BuildConfiguration)/</TestArchiveRuntimeDir>

<!-- project file to use when resolving ReferenceFromRuntime items -->
<RuntimeProjectFile Condition="'$(RuntimeProjectFile)' == ''">$(ProjectDir)\external\runtime\runtime.depproj</RuntimeProjectFile>
Expand Down
39 changes: 35 additions & 4 deletions eng/Tools.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@

<!-- Need to keep in sync with CodeAnalysis.targets file. -->
<AnalyzerPropsFile>$(ArtifactsToolsetDir)Common\Tools.Analyzers.props</AnalyzerPropsFile>

<DotNetRoot Condition="'$(DotNetRoot)' == ''">$(RepoRoot).dotnet\</DotNetRoot>
<DotNetCmd>$(DotNetRoot)dotnet</DotNetCmd>
<DotNetCmd Condition="'$(OS)' == 'Windows_NT'">$(DotNetCmd).exe</DotNetCmd>
<GlobalToolsDir>$(ArtifactsDir)tools/</GlobalToolsDir>
</PropertyGroup>
<Import Project="$(MSBuildThisFileDirectory)dependencies.props" />

Expand Down Expand Up @@ -46,10 +51,6 @@
<BuildToolsPackageDir>$(PackagesDir)$(BuildToolsPackage)/$(BuildToolsPackageVersion)/lib/</BuildToolsPackageDir>
<CmdExt>cmd</CmdExt>
<CmdExt Condition="'$(OS)' != 'Windows_NT'">sh</CmdExt>
<DotNetRoot Condition="'$(DotNetRoot)' == ''">$(RepoRoot).dotnet\</DotNetRoot>
<DotNetCmd>$(DotNetRoot)dotnet</DotNetCmd>
<DotNetCmd Condition="'$(OS)' == 'Windows_NT'">$(DotNetCmd).exe</DotNetCmd>

<InitToolsCmdLine>$(BuildToolsPackageDir)init-tools.$(CmdExt) $(RepoRoot) $(DotNETCmd) $(ToolsDir) $(PackagesDir)</InitToolsCmdLine>
</PropertyGroup>

Expand All @@ -61,6 +62,36 @@
<OnError ExecuteTargets="DumpInitToolsLog" />
</Target>

<Target Name="InitGlobalTools" AfterTargets="Restore">

<ItemGroup>
<RepoTool Include="coverlet.console" Version="$(CoverletConsolePackageVersion)" />
<RepoTool Include="dotnet-reportgenerator-globaltool" Version="$(DotNetReportGeneratorGlobalToolPackageVersion)" />
</ItemGroup>

<PropertyGroup>
<RepoToolIdentifierEscaped>$([System.Text.RegularExpressions.Regex]::Escape('%(RepoTool.Identity)'))</RepoToolIdentifierEscaped>
<RepoToolVersionEscaped>$([System.Text.RegularExpressions.Regex]::Escape('%(RepoTool.Version)'))</RepoToolVersionEscaped>
</PropertyGroup>

<Exec Condition="Exists($(GlobalToolsDir))"
Command="$(DotNetCmd) tool list --tool-path $(GlobalToolsDir)"
ConsoleToMsBuild="true"
ContinueOnError="WarnAndContinue">
<Output TaskParameter="ConsoleOutput" PropertyName="DotNetListToolsOutput" />
</Exec>

<Exec Condition="Exists($(GlobalToolsDir)) AND !$([System.Text.RegularExpressions.Regex]::IsMatch('$(DotNetListToolsOutput)', '$(RepoToolIdentifierEscaped)\s+$(RepoToolVersionEscaped)'))"
Command="$(DotNetCmd) tool uninstall --tool-path $(GlobalToolsDir) %(RepoTool.Identity)"
ContinueOnError="WarnAndContinue" />

<!-- Creates the global tools dir if it doesn't exist yet. -->
<Exec Condition="!$([System.Text.RegularExpressions.Regex]::IsMatch('$(DotNetListToolsOutput)', '$(RepoToolIdentifierEscaped)\s+$(RepoToolVersionEscaped)'))"
Command="$(DotNetCmd) tool install --tool-path $(GlobalToolsDir) %(RepoTool.Identity) --version %(RepoTool.Version)"
ContinueOnError="WarnAndContinue" />

</Target>

<Target Name="DumpInitToolsLog">
<Message Text="Init-tools failed dumping log file $(RepoRoot)init-tools.log" />
<Message Condition="Exists('$(RepoRoot)init-tools.log')" Text="$([System.IO.File]::ReadAllText('$(RepoRoot)init-tools.log'))" />
Expand Down
4 changes: 4 additions & 0 deletions eng/dependencies.props
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
<TraceEventPackageVersion>2.0.5</TraceEventPackageVersion>
<UAPToolsPackageVersion>1.0.23</UAPToolsPackageVersion>

<!-- Code coverage package version -->
<CoverletConsolePackageVersion>1.3.0</CoverletConsolePackageVersion>
<DotNetReportGeneratorGlobalToolPackageVersion>4.0.4</DotNetReportGeneratorGlobalToolPackageVersion>

<!-- Roslyn optimization data package version -->
<MicrosoftDotNetIBCMergePackageVersion>4.6.0-alpha-00001</MicrosoftDotNetIBCMergePackageVersion>
<TestILCAmd64retPackageVersion>$(ProjectNTfsTestILCPackageVersion)</TestILCAmd64retPackageVersion>
Expand Down
1 change: 1 addition & 0 deletions external/test-runtime/XUnit.Runtime.depproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<XUnitAdapter Condition="'$(TargetGroup)' == 'netfx'">xunit.runner.visualstudio.testadapter</XUnitAdapter>
<MicrosoftNetTestSdkPackageName>Microsoft.NET.Test.Sdk</MicrosoftNetTestSdkPackageName>
<TestPlatformHostPackageId>microsoft.testplatform.testhost</TestPlatformHostPackageId>
<MicrosoftDiagnosticsTracingTraceEventPackageName>Microsoft.Diagnostics.Tracing.TraceEvent</MicrosoftDiagnosticsTracingTraceEventPackageName>
<TestPlatformHost>testhost</TestPlatformHost>
<!-- Explicitly set Language to c# to handle the analyzer resolution in nuget -->
<Language Condition="'$(Language)' == ''">c#</Language>
Expand Down
9 changes: 0 additions & 9 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@
<AssemblySearchPaths>$(AssemblySearchPaths);$(RefPath);{RawFileName}</AssemblySearchPaths>
</PropertyGroup>

<!--
We need to filter the data to only the assembly being tested. Otherwise we will gather tons of data about other assemblies.
If the code being tested is part of the runtime itself, it requires special treatment.
-->
<PropertyGroup Condition="'$(AssemblyBeingTested)' == ''">
<_ProjectDirectoryUnderSourceDir>$(MSBuildProjectDirectory.SubString($(SourceDir.Length)))</_ProjectDirectoryUnderSourceDir>
<AssemblyBeingTested>$(_ProjectDirectoryUnderSourceDir.SubString(0, $(_ProjectDirectoryUnderSourceDir.IndexOfAny("\\/"))))</AssemblyBeingTested>
</PropertyGroup>

<ItemGroup>
<CoverageExcludeFile Include="$(SourceDir)Common/src/System/SR.*" />
<CoverageExcludeFile Include="$(SourceDir)Common/src/System/NotImplemented.cs" />
Expand Down

0 comments on commit a1a67e3

Please sign in to comment.