Skip to content

Commit

Permalink
Add workload resolver (#13782)
Browse files Browse the repository at this point in the history
* Add workload SDK resolver project

* Import workload props and targets

* Resolve workload manifests and packs from dotnet root

* Resolve workload manifests on .NET Framework

* Read workload manifest from XML

* Include workload resolver in MSBuildSdkResolver

* Update to new workload manifest reader APIs, compile with MSBuild SDK resolver

* Switch to sdk-manifests folder

* Don't crash on workload manifest folder without manifest

* Add test workloads to layout

* Add workload tests

* Code review feedback

* Put workload resolution behind feature flag

* Use MSBuild SDK resolver to import workload manifest targets

This allows the calculation of the manifest paths to be centralized in C# code instead of
duplicated in MSBuild XML.

* Add localized error message for missing workloads

* Use workload resolver to get workload pack paths

* Rename workload SDK resolver to avoid namespace conflict

* Fix testing with resolver on full framework

* Use stage 2 MSBuild SDK resolver for full Framework tests

* Fix compiling on non-Windows

* Retarget workload / resolver projects to net472

* Fix error packing SDK Resolver

* Disable workload tests on full framework

* Fix casing mismatch in test workload
  • Loading branch information
dsplaisted authored Sep 27, 2020
1 parent ec443d4 commit ea0db05
Show file tree
Hide file tree
Showing 52 changed files with 720 additions and 43 deletions.
7 changes: 7 additions & 0 deletions sdk.sln
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WorkloadManifestValidator",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.NET.Sdk.WorkloadManifestReader.Tests", "src\Tests\Microsoft.NET.Sdk.WorkloadManifestReader.Tests\Microsoft.NET.Sdk.WorkloadManifestReader.Tests.csproj", "{988D4839-B97F-42BB-A045-C79157CA7780}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver", "src\Resolvers\Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver\Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver.csproj", "{56F189B0-6A8E-4A9D-B7AE-24241204E98D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -472,6 +474,10 @@ Global
{988D4839-B97F-42BB-A045-C79157CA7780}.Debug|Any CPU.Build.0 = Debug|Any CPU
{988D4839-B97F-42BB-A045-C79157CA7780}.Release|Any CPU.ActiveCfg = Release|Any CPU
{988D4839-B97F-42BB-A045-C79157CA7780}.Release|Any CPU.Build.0 = Release|Any CPU
{56F189B0-6A8E-4A9D-B7AE-24241204E98D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{56F189B0-6A8E-4A9D-B7AE-24241204E98D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{56F189B0-6A8E-4A9D-B7AE-24241204E98D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{56F189B0-6A8E-4A9D-B7AE-24241204E98D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -559,6 +565,7 @@ Global
{C22A85E0-C09F-4E2D-81F6-82AB97932FE2} = {8F22FBD6-BDC8-431E-8402-B7460D3A9724}
{565411E4-E89D-4DF3-ADD5-55D3295F30EE} = {8F22FBD6-BDC8-431E-8402-B7460D3A9724}
{988D4839-B97F-42BB-A045-C79157CA7780} = {580D1AE7-AA8F-4912-8B76-105594E00B3B}
{56F189B0-6A8E-4A9D-B7AE-24241204E98D} = {8F22FBD6-BDC8-431E-8402-B7460D3A9724}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FB8F26CE-4DE6-433F-B32A-79183020BBD6}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"version": 5,
"workloads": {
"microsoft-net-sdk-testworkload": {
"description": "SDK Test Workload",
"packs": [
"Microsoft.NET.Sdk.TestWorkload.Pack"
]
},
"microsoft-net-sdk-missingtestworkload": {
"description": "SDK Test Workload (missing)",
"packs": [
"Microsoft.NET.Sdk.MissingTestWorkload.Pack"
]
}
},
"packs": {
"Microsoft.NET.Sdk.TestWorkload.Pack": {
"kind": "sdk",
"version": "0.42.42"
},
"Microsoft.NET.Sdk.MissingTestWorkload.Pack": {
"kind": "sdk",
"version": "0.42.42"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project>
<Import Project="Sdk.targets"
Sdk="Microsoft.NET.SDK.TestWorkload.Pack"
Condition="'$(TargetPlatformIdentifier)'=='WorkloadTestPlatform'" />

<Import Project="Sdk.targets"
Sdk="Microsoft.NET.SDK.MissingTestWorkload.Pack"
Condition="'$(TargetPlatformIdentifier)'=='MissingWorkloadTestPlatform'" />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Default item includes (globs and implicit references) -->
<!-- <Import Project="..\targets\Microsoft.NET.Sdk.TestWorkload.DefaultItems.props" /> -->

<PropertyGroup>
<TestWorkloadAutoImportPropsImported>true</TestWorkloadAutoImportPropsImported>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<TargetPlatformSupported>true</TargetPlatformSupported>
<TargetPlatformVersion Condition="'$(TargetPlatformVersion)' == ''">42.0</TargetPlatformVersion>
</PropertyGroup>
<ItemGroup>
<SdkSupportedTargetPlatformVersion Include="42.0" />
</ItemGroup>
</Project>
2 changes: 2 additions & 0 deletions src/Cli/Microsoft.DotNet.Cli.Utils/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@
[assembly: InternalsVisibleTo("Microsoft.DotNet.Tools.Tests.Utilities, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.DotNet.ShellShim.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.DotNet.CommandFactory.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
[assembly: InternalsVisibleTo("Msbuild.Tests.Utilities, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.NET.TestFramework, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
[assembly: InternalsVisibleTo("Microsoft.DotNet.MSBuildSdkResolver, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
7 changes: 4 additions & 3 deletions src/Layout/redist/redist.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
<PackageReference Condition=" '$(DotNetBuildFromSource)' != 'true' " Include="NuGet.Localization" Version="$(NuGetProjectModelPackageVersion)" />
<PackageReference Include="NuGet.ProjectModel" Version="$(NuGetProjectModelPackageVersion)" />
<PackageReference Include="Microsoft.Net.Compilers.Toolset" Version="$(MicrosoftNetCompilersToolsetPackageVersion)" ExcludeAssets="All" />
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="$(MicrosoftCodeAnalysisNetAnalyzersVersion)" ExcludeAssets="All" GeneratePathProperty="true"/>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="$(MicrosoftNetCompilersToolsetPackageVersion)" ExcludeAssets="All" GeneratePathProperty="true"/>
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic.CodeStyle" Version="$(MicrosoftNetCompilersToolsetPackageVersion)" ExcludeAssets="All" GeneratePathProperty="true"/>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="$(MicrosoftCodeAnalysisNetAnalyzersVersion)" ExcludeAssets="All" GeneratePathProperty="true" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="$(MicrosoftNetCompilersToolsetPackageVersion)" ExcludeAssets="All" GeneratePathProperty="true" />
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic.CodeStyle" Version="$(MicrosoftNetCompilersToolsetPackageVersion)" ExcludeAssets="All" GeneratePathProperty="true" />

<!-- Lift up dependencies of dependencies to prevent build tasks from getting pinned to older versions -->
<PackageReference Include="System.CodeDom" Version="$(SystemCodeDomPackageVersion)" />
Expand All @@ -49,6 +49,7 @@
ReferenceOutputAssembly="false" />
<ProjectReference Include="..\..\Tasks\Microsoft.NET.Build.Extensions.Tasks\Microsoft.NET.Build.Extensions.Tasks.csproj"
ReferenceOutputAssembly="false" />
<ProjectReference Include="..\..\Resolvers\Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver\Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
21 changes: 21 additions & 0 deletions src/Layout/redist/targets/OverlaySdkOnLKG.targets
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,25 @@
<Exec Command="$(RedistLayoutPath)dotnet new"
EnvironmentVariables="DOTNET_CLI_HOME=$(ArtifactsTmpDir)" />
</Target>


<Target Name="PublishTestWorkloads"
AfterTargets="OverlaySdkOnLKG">
<PropertyGroup>
<!-- TODO: Update this to actually calculate the band (ie the band should still be 5.0.100 if the VersionPrefix is 5.0.101 -->
<VersionBand>$(VersionPrefix)</VersionBand>
</PropertyGroup>

<ItemGroup>
<WorkloadManifestContent Include="$(RepoRoot)\src\Assets\TestWorkloads\manifests\**\*.*" />
<WorkloadPackContent Include="$(RepoRoot)\src\Assets\TestWorkloads\packs\**\*.*" />
</ItemGroup>

<Copy SourceFiles="@(WorkloadManifestContent)"
DestinationFiles="@(WorkloadManifestContent->'$(RedistLayoutPath)\sdk-manifests\$(VersionBand)\%(RecursiveDir)%(Filename)%(Extension)')" />

<Copy SourceFiles="@(WorkloadPackContent)"
DestinationFiles="@(WorkloadPackContent->'$(RedistLayoutPath)\packs\%(RecursiveDir)%(Filename)%(Extension)')" />

</Target>
</Project>
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net472</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netstandard2.0</TargetFrameworks>
<TargetFrameworks>$(SdkTargetFramework);net472</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">$(SdkTargetFramework)</TargetFrameworks>
<PlatformTarget>AnyCPU</PlatformTarget>
<RuntimeIdentifiers Condition="'$(OS)' == 'Windows_NT'">win-x86;win-x64</RuntimeIdentifiers>
<WarningsAsErrors>true</WarningsAsErrors>
Expand Down
3 changes: 2 additions & 1 deletion src/Microsoft.DotNet.TemplateLocator/TemplateLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ public sealed class TemplateLocator
private IWorkloadManifestProvider? _workloadManifestProvider;
private IWorkloadResolver? _workloadResolver;
private readonly Lazy<NETCoreSdkResolver> _netCoreSdkResolver;

#nullable disable
public TemplateLocator()
: this(Environment.GetEnvironmentVariable, VSSettings.Ambient, null, null)
{
}
#nullable restore

/// <summary>
/// Test constructor
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// 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.

#nullable disable

namespace Microsoft.DotNet.MSBuildSdkResolver
{
// Note: This is SemVer 2.0.0 https://semver.org/spec/v2.0.0.html
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
using System.Linq;
using System.Reflection;

#nullable disable

namespace Microsoft.DotNet.MSBuildSdkResolver
{
// Thread-safety note:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,46 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net472</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netstandard2.0</TargetFrameworks>
<TargetFrameworks>$(SdkTargetFramework);net472</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">$(SdkTargetFramework)</TargetFrameworks>
<PlatformTarget>AnyCPU</PlatformTarget>
<RuntimeIdentifiers Condition="'$(OS)' == 'Windows_NT'">win-x86;win-x64</RuntimeIdentifiers>
<WarningsAsErrors>true</WarningsAsErrors>
<StrongNameKeyId>MicrosoftAspNetCore</StrongNameKeyId>
<IsPackable>true</IsPackable>

<Nullable>Enable</Nullable>

<UseSystemTextJson Condition="'$(TargetFramework)'!='netstandard2.0' And '$(TargetFramework)'!='net472'">True</UseSystemTextJson>
<DefineConstants Condition="'$(UseSystemTextJson)'=='True'">$(DefineConstants);USE_SYSTEM_TEXT_JSON</DefineConstants>

<!-- Create FileDefinitions items for ResolveHostfxrCopyLocalContent target -->
<EmitLegacyAssetsFileItems>true</EmitLegacyAssetsFileItems>

<!--https://github.com/NuGet/Home/issues/3891#issuecomment-377319939-->
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput>
</PropertyGroup>

<Target Name="CopyProjectReferencesToPackage" DependsOnTargets="ResolveReferences">
<Target Name="CopyProjectReferencesToPackage" DependsOnTargets="ResolveReferences" Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
<ItemGroup>
<BuildOutputInPackage Include="@(ReferenceCopyLocalPaths-&gt;WithMetadataValue('ReferenceSourceTarget', 'ProjectReference'))" />
</ItemGroup>
</Target>

<ItemGroup>
<EmbeddedResource Include="..\Microsoft.NET.Sdk.WorkloadManifestReader\Strings.resx" LinkBase="Resources" GenerateSource="True" Namespace="Microsoft.NET.Sdk.Localization"/>
</ItemGroup>

<Target Name="WriteFullFrameworkResolverManifest" AfterTargets="AfterBuild" Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
<ItemGroup>
<ManifestLines Include="&lt;SdkResolver&gt;" />
<ManifestLines Include="&lt;Path&gt;$(TargetPath)&lt;/Path&gt;" />
<ManifestLines Include="&lt;/SdkResolver&gt;" />
</ItemGroup>

<WriteLinesToFile File="$(OutputPath)\Resolver\$(AssemblyName)\$(AssemblyName).xml" Lines="@(ManifestLines)" Overwrite="true" WriteOnlyWhenDifferent="true" />
</Target>

<ItemGroup>
<EmbeddedResource Update="**\*.resx" GenerateSource="true" />
</ItemGroup>
Expand All @@ -33,16 +55,27 @@
<Reference Include="System.Core" />
</ItemGroup>

<!-- To reduce dll load (cause RPS perf regression). Directly compile files from Microsoft.DotNet.SdkResolver -->
<!-- To reduce dll load (cause RPS perf regression). Directly compile files from Microsoft.DotNet.SdkResolver, and the workload resolver -->
<ItemGroup>
<Compile Include="..\Microsoft.DotNet.SdkResolver\**\*.cs" LinkBase="Microsoft.DotNet.SdkResolver" />
<Compile Include="..\Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver\**\*.cs" LinkBase="Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver" />
<Compile Include="..\Microsoft.NET.Sdk.WorkloadManifestReader\**\*.cs" LinkBase="Microsoft.NET.Sdk.WorkloadManifestReader" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFrameworkIdentifier)' != '.NETFramework'">
<ProjectReference Include="..\..\Cli\Microsoft.DotNet.Cli.Utils\Microsoft.DotNet.Cli.Utils.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
<Reference Include="System" />
<Reference Include="System.Core" />
<PackageReference Include="Microsoft.VisualStudio.Setup.Configuration.Interop" Version="1.16.30" PrivateAssets="All" ExcludeAssets="Runtime" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Text.Json" Version="4.7.2" Condition="'$(UseSystemTextJson)'=='True'"/>
<PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" Condition="'$(UseSystemTextJson)'!='True'"/>
</ItemGroup>

<Target Name="ResolveHostfxrCopyLocalContent" Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'" DependsOnTargets="RunResolvePackageDependencies" BeforeTargets="AssignTargetPaths">
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
using System.Linq;
using System.Runtime.InteropServices;

#nullable disable

namespace Microsoft.DotNet.DotNetSdkResolver
{
internal class EnvironmentProvider
Expand Down
2 changes: 2 additions & 0 deletions src/Resolvers/Microsoft.DotNet.SdkResolver/Interop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
using System.Runtime.InteropServices;
using System.Text;

#nullable disable

namespace Microsoft.DotNet.DotNetSdkResolver
{
internal static partial class Interop
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net472</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netstandard2.0</TargetFrameworks>
<TargetFrameworks>$(SdkTargetFramework);net472</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">$(SdkTargetFramework)</TargetFrameworks>
<PlatformTarget>AnyCPU</PlatformTarget>
<RuntimeIdentifiers Condition="'$(OS)' == 'Windows_NT'">win-x86;win-x64</RuntimeIdentifiers>
<WarningsAsErrors>true</WarningsAsErrors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
using System.Text;
using Microsoft.Build.Framework;

#nullable disable

namespace Microsoft.DotNet.DotNetSdkResolver
{
public class NETCoreSdkResolver
Expand Down Expand Up @@ -176,7 +178,7 @@ public SdkResolutionResult ResolveNETCoreSdkDirectory(string globalJsonStartDir,
public string GetDotnetExeDirectory()
{
string environmentOverride = _getEnvironmentVariable("DOTNET_MSBUILD_SDK_RESOLVER_CLI_DIR");
if (environmentOverride != null)
if (!string.IsNullOrEmpty(environmentOverride))
{
return environmentOverride;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
using System;
using System.Diagnostics;

#nullable disable

namespace Microsoft.DotNet.DotNetSdkResolver
{
internal static class NETCoreSdkResolverNativeWrapper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using System.Collections.Generic;
using System.Text;

#nullable disable

namespace Microsoft.DotNet.DotNetSdkResolver
{
public class SdkResolutionResult
Expand Down
2 changes: 2 additions & 0 deletions src/Resolvers/Microsoft.DotNet.SdkResolver/VSSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
using Microsoft.VisualStudio.Setup.Configuration;
#endif

#nullable disable

namespace Microsoft.DotNet.DotNetSdkResolver
{
public sealed class VSSettings
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>$(SdkTargetFramework);net472</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">$(SdkTargetFramework)</TargetFrameworks>
<IsPackable>true</IsPackable>
</PropertyGroup>



<ItemGroup Condition="'$(TargetFrameworkIdentifier)' != '.NETFramework'">
<None Update="SdkResolvers\Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver\Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver.xml" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Update="**\*.resx" GenerateSource="true" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Build.Framework" Version="$(MicrosoftBuildPackageVersion)" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Microsoft.NET.Sdk.WorkloadManifestReader\Microsoft.NET.Sdk.WorkloadManifestReader.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFrameworkIdentifier)' != '.NETFramework'">
<ProjectReference Include="..\..\Cli\Microsoft.DotNet.Cli.Utils\Microsoft.DotNet.Cli.Utils.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
<ProjectReference Include="..\Microsoft.DotNet.SdkResolver\Microsoft.DotNet.SdkResolver.csproj" />
</ItemGroup>

<Target Name="WriteFullFrameworkResolverManifest" AfterTargets="AfterBuild" Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
<ItemGroup>
<ManifestLines Include="&lt;SdkResolver&gt;" />
<ManifestLines Include="&lt;Path&gt;$(TargetPath)&lt;/Path&gt;" />
<ManifestLines Include="&lt;/SdkResolver&gt;" />
</ItemGroup>

<WriteLinesToFile File="$(OutputPath)\SdkResolvers\$(AssemblyName)\$(AssemblyName).xml" Lines="@(ManifestLines)" Overwrite="true" WriteOnlyWhenDifferent="true" />
</Target>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<SdkResolver>
<Path>..\..\Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver.dll</Path>
</SdkResolver>
Loading

0 comments on commit ea0db05

Please sign in to comment.