Fix build break on non-Windows
And PR Feedback
This commit is contained in:
parent
c5258cd782
commit
a23568b4e5
7 changed files with 33 additions and 13 deletions
|
@ -46,7 +46,7 @@ namespace Microsoft.DotNet.Tools.DependencyInvoker
|
|||
{
|
||||
var exitCode = commandFactory.Create(
|
||||
$"dotnet-{dotnetParams.Command}",
|
||||
Enumerable.Empty<string>(),
|
||||
dotnetParams.RemainingArguments,
|
||||
projectContext.TargetFramework,
|
||||
dotnetParams.Config)
|
||||
.ForwardStdErr()
|
||||
|
|
|
@ -7,9 +7,9 @@ namespace ConsoleApplication
|
|||
public static void Main(string[] args)
|
||||
{
|
||||
#if NET451
|
||||
Console.WriteLine("Hello From .NETFramework,Version=v4.5.1");
|
||||
Console.WriteLine($"Hello {string.Join(" ", args)} From .NETFramework,Version=v4.5.1");
|
||||
#elif NETSTANDARD1_5
|
||||
Console.WriteLine("Hello From .NETStandardApp,Version=v1.5");
|
||||
Console.WriteLine($"Hello {string.Join(" ", args)} From .NETStandardApp,Version=v1.5");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,6 +48,11 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
"dotnet-test.UnitTests",
|
||||
"dotnet-test.Tests"
|
||||
};
|
||||
|
||||
public static readonly dynamic[] ConditionalTestAssets = new[]
|
||||
{
|
||||
new { Path = "AppWithDirectDependencyDesktopAndPortable", Skip = new Func<bool>(() => !CurrentPlatform.IsWindows) }
|
||||
};
|
||||
|
||||
[Target(nameof(PrepareTargets.Init), nameof(SetupTests), nameof(RestoreTests), nameof(BuildTests), nameof(RunTests), nameof(ValidateDependencies))]
|
||||
public static BuildTargetResult Test(BuildTargetContext c) => c.Success();
|
||||
|
@ -55,7 +60,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
[Target(nameof(SetupTestPackages), nameof(SetupTestProjects))]
|
||||
public static BuildTargetResult SetupTests(BuildTargetContext c) => c.Success();
|
||||
|
||||
[Target(nameof(RestoreTestAssetPackages), nameof(BuildTestAssetPackages))]
|
||||
[Target(nameof(RestoreTestAssetPackages), nameof(RestoreDesktopTestAssetProjects), nameof(BuildTestAssetPackages))]
|
||||
public static BuildTargetResult SetupTestPackages(BuildTargetContext c) => c.Success();
|
||||
|
||||
[Target(nameof(RestoreTestAssetProjects), nameof(BuildTestAssetProjects))]
|
||||
|
@ -101,6 +106,19 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
[BuildPlatforms(BuildPlatform.Windows)]
|
||||
public static BuildTargetResult RestoreDesktopTestAssetProjects(BuildTargetContext c)
|
||||
{
|
||||
var dotnet = DotNetCli.Stage2;
|
||||
|
||||
dotnet.Restore("--verbosity", "verbose", "--disable-parallel", "--fallbacksource", Dirs.TestPackages)
|
||||
.WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "DesktopTestProjects"))
|
||||
.Execute().EnsureSuccessful();
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
[Target(nameof(CleanTestPackages))]
|
||||
public static BuildTargetResult BuildTestAssetPackages(BuildTargetContext c)
|
||||
{
|
||||
|
@ -148,6 +166,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
var nobuildFileName = ".noautobuild";
|
||||
string testProjectsRoot = Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "TestProjects");
|
||||
var projects = Directory.GetFiles(testProjectsRoot, "project.json", SearchOption.AllDirectories)
|
||||
.Where(p => !ConditionalTestAssets.Where(s => !s.Skip() && p.EndsWith(Path.Combine(s.Path, "project.json"))).Any())
|
||||
.Where(p => !File.Exists(Path.Combine(Path.GetDirectoryName(p), nobuildFileName)));
|
||||
|
||||
foreach (var project in projects)
|
||||
|
|
|
@ -42,9 +42,9 @@ namespace Microsoft.DotNet.Tests
|
|||
|
||||
// need conditional theories so we can skip on non-Windows
|
||||
[Theory]
|
||||
[InlineData(".NETStandardApp,Version=v1.5")]
|
||||
[InlineData(".NETFramework,Version=v4.5.1")]
|
||||
public void TestFrameworkSpecificDependencyToolsCanBeInvoked(string framework)
|
||||
[InlineData(".NETStandardApp,Version=v1.5", "CoreFX")]
|
||||
[InlineData(".NETFramework,Version=v4.5.1", "NetFX")]
|
||||
public void TestFrameworkSpecificDependencyToolsCanBeInvoked(string framework, string args)
|
||||
{
|
||||
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
|
@ -59,9 +59,10 @@ namespace Microsoft.DotNet.Tests
|
|||
.Pass();
|
||||
|
||||
CommandResult result = new DependencyToolInvokerCommand { WorkingDirectory = appDirectory }
|
||||
.ExecuteWithCapturedOutput(framework);
|
||||
.ExecuteWithCapturedOutput(framework, args);
|
||||
|
||||
result.Should().HaveStdOutContaining(framework);
|
||||
result.Should().HaveStdOutContaining(args);
|
||||
result.Should().NotHaveStdErr();
|
||||
result.Should().Pass();
|
||||
}
|
||||
|
@ -140,15 +141,15 @@ namespace Microsoft.DotNet.Tests
|
|||
{
|
||||
}
|
||||
|
||||
public override CommandResult Execute(string framework)
|
||||
public CommandResult Execute(string framework, string additionalArgs)
|
||||
{
|
||||
var args = $"dependency-tool-invoker desktop-and-portable --framework {framework}";
|
||||
var args = $"dependency-tool-invoker desktop-and-portable --framework {framework} {additionalArgs}";
|
||||
return base.Execute(args);
|
||||
}
|
||||
|
||||
public override CommandResult ExecuteWithCapturedOutput(string framework)
|
||||
public CommandResult ExecuteWithCapturedOutput(string framework, string additionalArgs)
|
||||
{
|
||||
var args = $"dependency-tool-invoker desktop-and-portable --framework {framework}";
|
||||
var args = $"dependency-tool-invoker desktop-and-portable --framework {framework} {additionalArgs}";
|
||||
return base.ExecuteWithCapturedOutput(args);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
"../../TestAssets/TestProjects/AppWithDirectAndToolDependency/**/*",
|
||||
"../../TestAssets/TestProjects/AppWithDirectDependency/**/*",
|
||||
"../../TestAssets/TestProjects/AppWithToolDependency/**/*",
|
||||
"../../TestAssets/TestProjects/AppWithDirectDependencyDesktopAndPortable/**/*"
|
||||
"../../TestAssets/DesktopTestProjects/AppWithDirectDependencyDesktopAndPortable/**/*"
|
||||
],
|
||||
"testRunner": "xunit"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue