Fix build break on non-Windows

And PR Feedback
This commit is contained in:
piotrp 2016-03-28 04:18:59 -07:00 committed by Piotr Puszkiewicz
parent c5258cd782
commit a23568b4e5
7 changed files with 33 additions and 13 deletions

View file

@ -46,7 +46,7 @@ namespace Microsoft.DotNet.Tools.DependencyInvoker
{ {
var exitCode = commandFactory.Create( var exitCode = commandFactory.Create(
$"dotnet-{dotnetParams.Command}", $"dotnet-{dotnetParams.Command}",
Enumerable.Empty<string>(), dotnetParams.RemainingArguments,
projectContext.TargetFramework, projectContext.TargetFramework,
dotnetParams.Config) dotnetParams.Config)
.ForwardStdErr() .ForwardStdErr()

View file

@ -7,9 +7,9 @@ namespace ConsoleApplication
public static void Main(string[] args) public static void Main(string[] args)
{ {
#if NET451 #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 #elif NETSTANDARD1_5
Console.WriteLine("Hello From .NETStandardApp,Version=v1.5"); Console.WriteLine($"Hello {string.Join(" ", args)} From .NETStandardApp,Version=v1.5");
#endif #endif
} }
} }

View file

@ -48,6 +48,11 @@ namespace Microsoft.DotNet.Cli.Build
"dotnet-test.UnitTests", "dotnet-test.UnitTests",
"dotnet-test.Tests" "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))] [Target(nameof(PrepareTargets.Init), nameof(SetupTests), nameof(RestoreTests), nameof(BuildTests), nameof(RunTests), nameof(ValidateDependencies))]
public static BuildTargetResult Test(BuildTargetContext c) => c.Success(); public static BuildTargetResult Test(BuildTargetContext c) => c.Success();
@ -55,7 +60,7 @@ namespace Microsoft.DotNet.Cli.Build
[Target(nameof(SetupTestPackages), nameof(SetupTestProjects))] [Target(nameof(SetupTestPackages), nameof(SetupTestProjects))]
public static BuildTargetResult SetupTests(BuildTargetContext c) => c.Success(); 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(); public static BuildTargetResult SetupTestPackages(BuildTargetContext c) => c.Success();
[Target(nameof(RestoreTestAssetProjects), nameof(BuildTestAssetProjects))] [Target(nameof(RestoreTestAssetProjects), nameof(BuildTestAssetProjects))]
@ -101,6 +106,19 @@ namespace Microsoft.DotNet.Cli.Build
return c.Success(); 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))] [Target(nameof(CleanTestPackages))]
public static BuildTargetResult BuildTestAssetPackages(BuildTargetContext c) public static BuildTargetResult BuildTestAssetPackages(BuildTargetContext c)
{ {
@ -148,6 +166,7 @@ namespace Microsoft.DotNet.Cli.Build
var nobuildFileName = ".noautobuild"; var nobuildFileName = ".noautobuild";
string testProjectsRoot = Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "TestProjects"); string testProjectsRoot = Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "TestProjects");
var projects = Directory.GetFiles(testProjectsRoot, "project.json", SearchOption.AllDirectories) 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))); .Where(p => !File.Exists(Path.Combine(Path.GetDirectoryName(p), nobuildFileName)));
foreach (var project in projects) foreach (var project in projects)

View file

@ -42,9 +42,9 @@ namespace Microsoft.DotNet.Tests
// need conditional theories so we can skip on non-Windows // need conditional theories so we can skip on non-Windows
[Theory] [Theory]
[InlineData(".NETStandardApp,Version=v1.5")] [InlineData(".NETStandardApp,Version=v1.5", "CoreFX")]
[InlineData(".NETFramework,Version=v4.5.1")] [InlineData(".NETFramework,Version=v4.5.1", "NetFX")]
public void TestFrameworkSpecificDependencyToolsCanBeInvoked(string framework) public void TestFrameworkSpecificDependencyToolsCanBeInvoked(string framework, string args)
{ {
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{ {
@ -59,9 +59,10 @@ namespace Microsoft.DotNet.Tests
.Pass(); .Pass();
CommandResult result = new DependencyToolInvokerCommand { WorkingDirectory = appDirectory } CommandResult result = new DependencyToolInvokerCommand { WorkingDirectory = appDirectory }
.ExecuteWithCapturedOutput(framework); .ExecuteWithCapturedOutput(framework, args);
result.Should().HaveStdOutContaining(framework); result.Should().HaveStdOutContaining(framework);
result.Should().HaveStdOutContaining(args);
result.Should().NotHaveStdErr(); result.Should().NotHaveStdErr();
result.Should().Pass(); 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); 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); return base.ExecuteWithCapturedOutput(args);
} }
} }

View file

@ -25,7 +25,7 @@
"../../TestAssets/TestProjects/AppWithDirectAndToolDependency/**/*", "../../TestAssets/TestProjects/AppWithDirectAndToolDependency/**/*",
"../../TestAssets/TestProjects/AppWithDirectDependency/**/*", "../../TestAssets/TestProjects/AppWithDirectDependency/**/*",
"../../TestAssets/TestProjects/AppWithToolDependency/**/*", "../../TestAssets/TestProjects/AppWithToolDependency/**/*",
"../../TestAssets/TestProjects/AppWithDirectDependencyDesktopAndPortable/**/*" "../../TestAssets/DesktopTestProjects/AppWithDirectDependencyDesktopAndPortable/**/*"
], ],
"testRunner": "xunit" "testRunner": "xunit"
} }