Add msbuild sdk resolver
This commit is contained in:
parent
38b3e21c99
commit
d26b41a0c3
13 changed files with 429 additions and 3 deletions
|
@ -76,6 +76,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dotnet-store.Tests", "dotne
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dotnet-back-compat.Tests", "dotnet-back-compat.Tests\dotnet-back-compat.Tests.csproj", "{27351B2F-325B-4843-9F4C-BC53FD06A7B5}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DotNet.MSBuildSdkResolver.Tests", "Microsoft.DotNet.MSBuildSdkResolver.Tests\Microsoft.DotNet.MSBuildSdkResolver.Tests.csproj", "{42A0CAB4-FFAD-47D4-9880-C0F4EDCF93DE}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
@ -506,6 +508,18 @@ Global
|
|||
{27351B2F-325B-4843-9F4C-BC53FD06A7B5}.Release|x64.Build.0 = Release|Any CPU
|
||||
{27351B2F-325B-4843-9F4C-BC53FD06A7B5}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{27351B2F-325B-4843-9F4C-BC53FD06A7B5}.Release|x86.Build.0 = Release|Any CPU
|
||||
{42A0CAB4-FFAD-47D4-9880-C0F4EDCF93DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{42A0CAB4-FFAD-47D4-9880-C0F4EDCF93DE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{42A0CAB4-FFAD-47D4-9880-C0F4EDCF93DE}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{42A0CAB4-FFAD-47D4-9880-C0F4EDCF93DE}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{42A0CAB4-FFAD-47D4-9880-C0F4EDCF93DE}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{42A0CAB4-FFAD-47D4-9880-C0F4EDCF93DE}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{42A0CAB4-FFAD-47D4-9880-C0F4EDCF93DE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{42A0CAB4-FFAD-47D4-9880-C0F4EDCF93DE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{42A0CAB4-FFAD-47D4-9880-C0F4EDCF93DE}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{42A0CAB4-FFAD-47D4-9880-C0F4EDCF93DE}.Release|x64.Build.0 = Release|Any CPU
|
||||
{42A0CAB4-FFAD-47D4-9880-C0F4EDCF93DE}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{42A0CAB4-FFAD-47D4-9880-C0F4EDCF93DE}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
// 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.Collections.Generic;
|
||||
using Microsoft.Build.Framework;
|
||||
using Xunit;
|
||||
using System.Linq;
|
||||
using Xunit.Abstractions;
|
||||
using System;
|
||||
using Microsoft.DotNet.MSBuildSdkResolver;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Utils.Tests
|
||||
{
|
||||
public class GivenAnMSBuildSdkResolver
|
||||
{
|
||||
private ITestOutputHelper _logger;
|
||||
|
||||
public GivenAnMSBuildSdkResolver(ITestOutputHelper logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ItHasCorrectNameAndPriority()
|
||||
{
|
||||
var resolver = new DotNetMSBuildSdkResolver();
|
||||
|
||||
Assert.Equal(5000, resolver.Priority);
|
||||
Assert.Equal("Microsoft.DotNet.MSBuildSdkResolver", resolver.Name);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ItCallsNativeCodeWithoutCrashing() // WIP: placeholder to get plumbing through
|
||||
{
|
||||
var resolver = new DotNetMSBuildSdkResolver();
|
||||
var result = (MockResult)resolver.Resolve(
|
||||
new SdkReference("Microsoft.NET.Sdk", null, null),
|
||||
new MockContext(),
|
||||
new MockFactory());
|
||||
|
||||
_logger.WriteLine($"success: {result.Success}");
|
||||
_logger.WriteLine($"errors: {string.Join(Environment.NewLine, result.Errors ?? Array.Empty<string>())}");
|
||||
_logger.WriteLine($"warnings: {string.Join(Environment.NewLine, result.Warnings ?? Array.Empty<string>())}");
|
||||
_logger.WriteLine($"path: {result.Path}");
|
||||
_logger.WriteLine($"version: {result.Version}");
|
||||
}
|
||||
|
||||
private sealed class MockContext : SdkResolverContext
|
||||
{
|
||||
}
|
||||
|
||||
private sealed class MockFactory : SdkResultFactory
|
||||
{
|
||||
public override SdkResult IndicateFailure(IEnumerable<string> errors, IEnumerable<string> warnings = null)
|
||||
=> new MockResult { Success = false, Errors = errors, Warnings = warnings };
|
||||
|
||||
public override SdkResult IndicateSuccess(string path, string version, IEnumerable<string> warnings = null)
|
||||
=> new MockResult { Success = true, Path = path, Version = version, Warnings = warnings };
|
||||
}
|
||||
|
||||
private sealed class MockResult : SdkResult
|
||||
{
|
||||
public new bool Success { get => base.Success; set => base.Success = value; }
|
||||
public string Version { get; set; }
|
||||
public string Path { get; set; }
|
||||
public IEnumerable<string> Errors { get; set; }
|
||||
public IEnumerable<string> Warnings { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net46;$(CliTargetFramework)</TargetFrameworks>
|
||||
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">$(CliTargetFramework)</TargetFrameworks>
|
||||
<RuntimeFrameworkVersion>$(CLI_SharedFrameworkVersion)</RuntimeFrameworkVersion>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AssemblyOriginatorKeyFile>../../tools/Key.snk</AssemblyOriginatorKeyFile>
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Microsoft.DotNet.MSBuildSdkResolver\Microsoft.DotNet.MSBuildSdkResolver.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
|
||||
<PackageReference Include="xunit" Version="2.2.0" />
|
||||
<PackageReference Include="runtime.linux-x64.Microsoft.NETCore.DotNetHostResolver" Version="$(CLI_SharedFrameworkVersion)" />
|
||||
<PackageReference Include="runtime.osx-x64.Microsoft.NETCore.DotNetHostResolver" Version="$(CLI_SharedFrameworkVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"shadowCopy": false
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue