diff --git a/TestAssets/TestProjects/TestAppWithWrapperProjectDependency/TestApp/Program.cs b/TestAssets/TestProjects/TestAppWithWrapperProjectDependency/TestApp/Program.cs new file mode 100644 index 000000000..ac3163a58 --- /dev/null +++ b/TestAssets/TestProjects/TestAppWithWrapperProjectDependency/TestApp/Program.cs @@ -0,0 +1,17 @@ +// 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; +using System.Diagnostics; + +namespace TestApp +{ + public class Program + { + public static int Main(string[] args) + { + Console.WriteLine(TestLibrary.Helper.GetMessage()); + return 100; + } + } +} diff --git a/TestAssets/TestProjects/TestAppWithWrapperProjectDependency/TestApp/TestApp.xproj b/TestAssets/TestProjects/TestAppWithWrapperProjectDependency/TestApp/TestApp.xproj new file mode 100644 index 000000000..4cef17daa --- /dev/null +++ b/TestAssets/TestProjects/TestAppWithWrapperProjectDependency/TestApp/TestApp.xproj @@ -0,0 +1,20 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + + 58808bbc-371e-47d6-a3d0-4902145eda4e + TestApp + ..\..\artifacts\obj\$(MSBuildProjectName) + ..\..\artifacts\bin\$(MSBuildProjectName)\ + + + + 2.0 + + + diff --git a/TestAssets/TestProjects/TestAppWithWrapperProjectDependency/TestApp/project.json b/TestAssets/TestProjects/TestAppWithWrapperProjectDependency/TestApp/project.json new file mode 100644 index 000000000..64ba761af --- /dev/null +++ b/TestAssets/TestProjects/TestAppWithWrapperProjectDependency/TestApp/project.json @@ -0,0 +1,17 @@ +{ + "version": "1.0.0-*", + "compilationOptions": { + "emitEntryPoint": true, + "preserveCompilationContext": true + }, + + "dependencies": { + "TestLibrary": { "target":"project", "version":"1.0.0-*" }, + + "NETStandard.Library": "1.0.0-rc2-23811" + }, + + "frameworks": { + "dnxcore50": { } + } +} diff --git a/TestAssets/TestProjects/TestAppWithWrapperProjectDependency/TestLibrary/.noautobuild b/TestAssets/TestProjects/TestAppWithWrapperProjectDependency/TestLibrary/.noautobuild new file mode 100644 index 000000000..8f7edc4ac --- /dev/null +++ b/TestAssets/TestProjects/TestAppWithWrapperProjectDependency/TestLibrary/.noautobuild @@ -0,0 +1 @@ +noautobuild \ No newline at end of file diff --git a/TestAssets/TestProjects/TestAppWithWrapperProjectDependency/TestLibrary/bin/Debug/dnxcore50/TestLibrary.dll b/TestAssets/TestProjects/TestAppWithWrapperProjectDependency/TestLibrary/bin/Debug/dnxcore50/TestLibrary.dll new file mode 100644 index 000000000..bfd7fd465 Binary files /dev/null and b/TestAssets/TestProjects/TestAppWithWrapperProjectDependency/TestLibrary/bin/Debug/dnxcore50/TestLibrary.dll differ diff --git a/TestAssets/TestProjects/TestAppWithWrapperProjectDependency/TestLibrary/bin/Debug/dnxcore50/TestLibrary.pdb b/TestAssets/TestProjects/TestAppWithWrapperProjectDependency/TestLibrary/bin/Debug/dnxcore50/TestLibrary.pdb new file mode 100644 index 000000000..36cc512f7 Binary files /dev/null and b/TestAssets/TestProjects/TestAppWithWrapperProjectDependency/TestLibrary/bin/Debug/dnxcore50/TestLibrary.pdb differ diff --git a/TestAssets/TestProjects/TestAppWithWrapperProjectDependency/TestLibrary/bin/Debug/dnxcore50/TestLibrary.xml b/TestAssets/TestProjects/TestAppWithWrapperProjectDependency/TestLibrary/bin/Debug/dnxcore50/TestLibrary.xml new file mode 100644 index 000000000..92371c77c --- /dev/null +++ b/TestAssets/TestProjects/TestAppWithWrapperProjectDependency/TestLibrary/bin/Debug/dnxcore50/TestLibrary.xml @@ -0,0 +1,14 @@ + + + + TestLibraryWithConfiguration + + + + + Gets the message from the helper. This comment is here to help test XML documentation file generation, please do not remove it. + + A message + + + diff --git a/TestAssets/TestProjects/TestAppWithWrapperProjectDependency/TestLibrary/project.json b/TestAssets/TestProjects/TestAppWithWrapperProjectDependency/TestLibrary/project.json new file mode 100644 index 000000000..10bf5d798 --- /dev/null +++ b/TestAssets/TestProjects/TestAppWithWrapperProjectDependency/TestLibrary/project.json @@ -0,0 +1,10 @@ +{ + "frameworks": { + "dnxcore50": { + "bin": { + "assembly": "bin\\{configuration}\\dnxcore50\\TestLibrary.dll", + "pdb": "bin\\{configuration}\\dnxcore50\\TestLibrary.pdb" + } + } + } +} \ No newline at end of file diff --git a/TestAssets/TestProjects/TestAppWithWrapperProjectDependency/global.json b/TestAssets/TestProjects/TestAppWithWrapperProjectDependency/global.json new file mode 100644 index 000000000..3a4684c26 --- /dev/null +++ b/TestAssets/TestProjects/TestAppWithWrapperProjectDependency/global.json @@ -0,0 +1,3 @@ +{ + "projects": [ "."] +} \ No newline at end of file diff --git a/src/Microsoft.DotNet.ProjectModel/Compilation/LibraryExporter.cs b/src/Microsoft.DotNet.ProjectModel/Compilation/LibraryExporter.cs index ea5989e83..2ab423241 100644 --- a/src/Microsoft.DotNet.ProjectModel/Compilation/LibraryExporter.cs +++ b/src/Microsoft.DotNet.ProjectModel/Compilation/LibraryExporter.cs @@ -216,10 +216,14 @@ namespace Microsoft.DotNet.ProjectModel.Compilation var compileAsset = new LibraryAsset( project.Project.Name, null, - Path.GetFullPath(Path.Combine(project.Project.ProjectDirectory, assemblyPath))); + assemblyPath); builder.AddCompilationAssembly(compileAsset); - builder.AddRuntimeAsset(new LibraryAsset(Path.GetFileName(pdbPath), Path.GetFileName(pdbPath), pdbPath)); + builder.AddRuntimeAssembly(compileAsset); + if (File.Exists(pdbPath)) + { + builder.AddRuntimeAsset(new LibraryAsset(Path.GetFileName(pdbPath), Path.GetFileName(pdbPath), pdbPath)); + } } else if (project.Project.Files.SourceFiles.Any()) { @@ -286,7 +290,7 @@ namespace Microsoft.DotNet.ProjectModel.Compilation path = path.Replace("{configuration}", configuration); - return path; + return Path.Combine(project.ProjectDirectory, path); } private LibraryExport ExportFrameworkLibrary(LibraryDescription library) diff --git a/test/dotnet-build.Tests/WrappedProjectTests.cs b/test/dotnet-build.Tests/WrappedProjectTests.cs new file mode 100644 index 000000000..73f8ee102 --- /dev/null +++ b/test/dotnet-build.Tests/WrappedProjectTests.cs @@ -0,0 +1,36 @@ +using System; +using System.IO; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.DotNet.Cli.Utils; +using Microsoft.DotNet.Tools.Test.Utilities; +using FluentAssertions; +using Xunit; + +namespace Microsoft.DotNet.Tools.Builder.Tests +{ + public class WrappedProjectTests: TestBase + { + [Fact] + public void WrappedProjectFilesResolvedCorrectly() + { + var testInstance = TestAssetsManager.CreateTestInstance("TestAppWithWrapperProjectDependency") + .WithBuildArtifacts() + .WithLockFiles(); + + var root = testInstance.TestRoot; + + // run compile + var outputDir = Path.Combine(root, "bin"); + var testProject = ProjectUtils.GetProjectJson(root, "TestApp"); + var buildCommand = new BuildCommand(testProject, output: outputDir, framework: DefaultFramework); + var result = buildCommand.ExecuteWithCapturedOutput(); + result.Should().Pass(); + + new DirectoryInfo(outputDir).Should() + .HaveFiles(new [] { "TestLibrary.dll", "TestLibrary.pdb" }); + } + + } +}