From 1bfd7725b03a260574f54ad7c42146d1496823d7 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 24 Feb 2016 09:52:06 -0800 Subject: [PATCH] Fix wrapped project paht resolution --- .../TestApp/Program.cs | 17 +++++++++ .../TestApp/TestApp.xproj | 20 ++++++++++ .../TestApp/project.json | 17 +++++++++ .../TestLibrary/.noautobuild | 1 + .../bin/Debug/dnxcore50/TestLibrary.dll | Bin 0 -> 4096 bytes .../bin/Debug/dnxcore50/TestLibrary.pdb | Bin 0 -> 11776 bytes .../bin/Debug/dnxcore50/TestLibrary.xml | 14 +++++++ .../TestLibrary/project.json | 10 +++++ .../global.json | 3 ++ .../Compilation/LibraryExporter.cs | 10 +++-- .../dotnet-build.Tests/WrappedProjectTests.cs | 36 ++++++++++++++++++ 11 files changed, 125 insertions(+), 3 deletions(-) create mode 100644 TestAssets/TestProjects/TestAppWithWrapperProjectDependency/TestApp/Program.cs create mode 100644 TestAssets/TestProjects/TestAppWithWrapperProjectDependency/TestApp/TestApp.xproj create mode 100644 TestAssets/TestProjects/TestAppWithWrapperProjectDependency/TestApp/project.json create mode 100644 TestAssets/TestProjects/TestAppWithWrapperProjectDependency/TestLibrary/.noautobuild create mode 100644 TestAssets/TestProjects/TestAppWithWrapperProjectDependency/TestLibrary/bin/Debug/dnxcore50/TestLibrary.dll create mode 100644 TestAssets/TestProjects/TestAppWithWrapperProjectDependency/TestLibrary/bin/Debug/dnxcore50/TestLibrary.pdb create mode 100644 TestAssets/TestProjects/TestAppWithWrapperProjectDependency/TestLibrary/bin/Debug/dnxcore50/TestLibrary.xml create mode 100644 TestAssets/TestProjects/TestAppWithWrapperProjectDependency/TestLibrary/project.json create mode 100644 TestAssets/TestProjects/TestAppWithWrapperProjectDependency/global.json create mode 100644 test/dotnet-build.Tests/WrappedProjectTests.cs 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 0000000000000000000000000000000000000000..bfd7fd4653c7b2176a89fd231ba848c4e64e7f33 GIT binary patch literal 4096 zcmeHKPiz!b82?_oEp3671|$#&PAw=xGj7vDgorHd(soV%(Op_%Hlee-uiJsyna!Ko zvb{(({vlBl4~BT~WQ;cxOgI!1ZeANN8jU9|9*hV7go9CI{e5p{yTuK}7^4UIw(oo2 zzxTdB^X8k^i5K3cRw9aFtgjQTVrEEc{9v>Kb^NhU;&iift!Gt?uk~aXZQrOUucWN9 zQLtRs3yi!pRMj{Hture~md}Sp*owzEeyjiS9=0nB9PRqHSP) zL%{ntgnxlB!tm>s9pK063}!QswE***oS%Wgx&FyN#Pg=|RRJm;TM`5(+J&(Rl8D|^ z((z!(vC=#S?-j?`1WBTyO{^vtxvl_?t%cgCW)QssAA*H{19m0^ZN)mQ?*}8|+Ng4eYX{Ib{cO+;%0UWWHJ|S$RjE3GfK>)j(3#QY9IT zpi#&xp1Rynobi2G&O6H^wj*by@@>y;R;JwrPnE3zO3P`o8urQ++tJz?=~y*Q`Hfwo z2-ys(yzSV*azh(s6&ab)?l^dqv6jbd%1S>NxAV$U%X4!NyCVUAK|q*}5I(vOOaF!7+kPUSCQ z!(Pe3oZ1Ty#2uOi;sRXV-7S4(UwE(FH+JJshO9EiFHt@dLl!xBJSf(DLy<^Zh z_<0-l3KD3jNr>x4P=bo(T~yu`pY65?KB3z{^rMB~hZZBK zO*05l(5}?vg<((0zUWDwS~|u?A=JM+{I2iEPJ0evpb^YuQknPO`17c9c4qE8(G6^SPoIxH8BU96QG+f{$(BYjRq7T>Fr@-$}{kZ8xW1j9k&J6%gOC zgkF8W1!kp~kAnV>r(E>S;4qe$HkfLL`nM(2T*Na-InIP-yHxf$VX5C1)~+AI9{MZY zyvsw$zgGdFAHp7@m3w{iOGt#5rb*6re0R8zBziaeV6q7GAn+_@=pyi0ngNx@O=}W- z8h9kUb=Dcv6n@Mcrx9zO1M_Gt9tIdI&shjoq% z;7U~0`PcI{sfc~}#zb^j$3KppN_ux*RY6DR3`*FA@1+LDB^}FDB)lecDzaR JQ1Cyfz#mg9>t_G} literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..36cc512f7a20503f97cbb5779046d99638be68a8 GIT binary patch literal 11776 zcmeHMZ)jUp6hAMES(ENn2w9LF6?Thzq*%D2qABuLz5{cGOdw-f3eBwv9bJj+gVXZ?{ zS_dAOt|(|^5A@J4jck6y+ur<5ht`90Y_*F_+Ne_TGp$rsaH^o5Juu(=uTt}0&r^P# zZEwUnwDZ4zyI14dcV4+Lb@7GcgQv@<-nMkr zd;X&gbLP@zVxm%W0S~D8U%)vHz`8oTyZ7wMbK#?Dnttq<@BJ@!J@WR&KYj=w?RCn{ z@4oy@IDalYwVCK@Q*!FB$hykD6RT54X3b>orLH0Q7SJ`?_OJE%zLww4yf$?H%g>&> zFdN?30Pd?B6W6(xNLn|BDMJ?Yz_m-)E+LRRfmZ$7Goyw*c4#;=V%kOB&g2S4<_X=h zAG9ppwnX;vlKH%za|?sUa4B0Ff08@(nZ>*@dZ?7O4YQaT&c?jm#(1W}#U} zD6$8oP!tM|(8DY=cb(9&s!&8Hdl;elUPgert2%yITzcoP39Zasjy?L-Qyb0iwZ#VY zXwOf?VkTr?%*ZB2$ewAx+?sLum@)8lMg_Iu0qmqs+8l;9?;&Amc8ExMP6Nn@xqVo- zQ@UkkM|FzOiZJ?OZe@G43DNrSp7gk7>j!vU1ZXGu{a^R~dG_O{e@uS5A?W+$gUKOo zMk(s&af$rAcpwMQPjVgk1LSMra)bp!M$FaEFO(o^Wu64?6TtX_mClY27{u*wFeW#K zER4YPoyB>eoi>QGAA3O~&jHWn2;J-9B_2osI*8V| zeU6Jh&Y>&YI(2Sa9PkQi+5__YGFQnD|M_S_ejDcURJndUu+aPei)?0m&?xRt7V{>> zi`fIZMRBW?i;wBq5xq2AFmwBzio8+Kt@u)1^$>v~Fxc+;9jDSt#t@^3PMO}qcn>3j zCxH5c!tuimQta`=!47fn&R?axfIyr%Q z&wZfE^YP80Rg9}u|F=NA(&WZcu$zm5hj`yvU`z7^BHvhCbug?0P{M(rP{heg?oFX> zJW7=DXT~1J*I7wWz;}#gMy!QRjFZgkXaC7HfqM + + + 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" }); + } + + } +}