diff --git a/TestAssets/DesktopTestProjects/DesktopAppWithNativeDep/Program.cs b/TestAssets/DesktopTestProjects/DesktopAppWithNativeDep/Program.cs new file mode 100644 index 000000000..8ef303f2d --- /dev/null +++ b/TestAssets/DesktopTestProjects/DesktopAppWithNativeDep/Program.cs @@ -0,0 +1,11 @@ +using System; + +namespace DesktopAppWithNativeDep +{ + public static class Program + { + public static void Main(string[] args) + { + } + } +} diff --git a/TestAssets/DesktopTestProjects/DesktopAppWithNativeDep/project.json b/TestAssets/DesktopTestProjects/DesktopAppWithNativeDep/project.json new file mode 100644 index 000000000..ab5874964 --- /dev/null +++ b/TestAssets/DesktopTestProjects/DesktopAppWithNativeDep/project.json @@ -0,0 +1,12 @@ +{ + "version": "1.0.0-*", + "dependencies": { + "PackageWithFakeNativeDep": "1.0.0-*" + }, + "compilationOptions": { + "emitEntryPoint": true + }, + "frameworks": { + "net451": { } + } +} diff --git a/TestAssets/TestPackages/PackageWithFakeNativeDep/Lib.cs b/TestAssets/TestPackages/PackageWithFakeNativeDep/Lib.cs new file mode 100644 index 000000000..c0f79e226 --- /dev/null +++ b/TestAssets/TestPackages/PackageWithFakeNativeDep/Lib.cs @@ -0,0 +1,10 @@ +namespace PackageWithFakeNativeDep +{ + public static class Lib + { + public static string GetMessage() + { + return "Hello, World"; + } + } +} diff --git a/TestAssets/TestPackages/PackageWithFakeNativeDep/project.json b/TestAssets/TestPackages/PackageWithFakeNativeDep/project.json new file mode 100644 index 000000000..a6e1e5d21 --- /dev/null +++ b/TestAssets/TestPackages/PackageWithFakeNativeDep/project.json @@ -0,0 +1,9 @@ +{ + "version": "1.0.0", + "packInclude": { + "runtimes/": "runtimes/" + }, + "frameworks": { + "net45": {} + } +} diff --git a/TestAssets/TestPackages/PackageWithFakeNativeDep/runtimes/win7-x64/native/the-win-x64-version.txt b/TestAssets/TestPackages/PackageWithFakeNativeDep/runtimes/win7-x64/native/the-win-x64-version.txt new file mode 100644 index 000000000..ee3c10a16 --- /dev/null +++ b/TestAssets/TestPackages/PackageWithFakeNativeDep/runtimes/win7-x64/native/the-win-x64-version.txt @@ -0,0 +1 @@ +This is just a marker to ensure things are deployed right diff --git a/TestAssets/TestPackages/PackageWithFakeNativeDep/runtimes/win7-x86/native/the-win-x86-version.txt b/TestAssets/TestPackages/PackageWithFakeNativeDep/runtimes/win7-x86/native/the-win-x86-version.txt new file mode 100644 index 000000000..ee3c10a16 --- /dev/null +++ b/TestAssets/TestPackages/PackageWithFakeNativeDep/runtimes/win7-x86/native/the-win-x86-version.txt @@ -0,0 +1 @@ +This is just a marker to ensure things are deployed right diff --git a/scripts/dotnet-cli-build/TestPackageProjects.cs b/scripts/dotnet-cli-build/TestPackageProjects.cs index aa8656f55..5a486100f 100644 --- a/scripts/dotnet-cli-build/TestPackageProjects.cs +++ b/scripts/dotnet-cli-build/TestPackageProjects.cs @@ -25,6 +25,15 @@ namespace Microsoft.DotNet.Cli.Build public static readonly dynamic[] Projects = new[] { + new + { + Name = "PackageWithFakeNativeDep", + IsTool = false, + Path = "TestAssets/TestPackages/PackageWithFakeNativeDep", + IsApplicable = new Func(() => true), + VersionSuffix = s_testPackageBuildVersionSuffix, + Clean = true + }, new { Name = "dotnet-dependency-context-test", diff --git a/test/dotnet-publish.Tests/PublishDesktopTests.cs b/test/dotnet-publish.Tests/PublishDesktopTests.cs index bb23b8b65..19481e008 100644 --- a/test/dotnet-publish.Tests/PublishDesktopTests.cs +++ b/test/dotnet-publish.Tests/PublishDesktopTests.cs @@ -12,6 +12,26 @@ namespace Microsoft.DotNet.Tools.Publish.Tests { public class PublishDesktopTests : TestBase { + [WindowsOnlyTheory] + [InlineData(null, "the-win-x64-version.txt")] + [InlineData("win7-x64", "the-win-x64-version.txt")] + [InlineData("win7-x86", "the-win-x86-version.txt")] + public async Task DesktopApp_WithDependencyOnNativePackage_ProducesExpectedOutput(string runtime, string expectedOutputName) + { + var testInstance = TestAssetsManager.CreateTestInstance(Path.Combine("..", "DesktopTestProjects", "DesktopAppWithNativeDep")) + .WithLockFiles(); + + var publishCommand = new PublishCommand(testInstance.TestRoot, runtime: runtime); + var result = await publishCommand.ExecuteAsync(); + + result.Should().Pass(); + + // Test the output + var outputDir = publishCommand.GetOutputDirectory(portable: false); + outputDir.Should().HaveFile(expectedOutputName); + outputDir.Should().HaveFile(publishCommand.GetOutputExecutable()); + } + [WindowsOnlyTheory] [InlineData("KestrelDesktopWithRuntimes", "http://localhost:20201", null, "libuv.dll", true)] [InlineData("KestrelDesktopWithRuntimes", "http://localhost:20202", "win7-x64", "libuv.dll", true)]