Skip to content

Commit

Permalink
Fixed processing projects with duplicated sections with explicit outp…
Browse files Browse the repository at this point in the history
…ut paths
  • Loading branch information
glakartur committed Jul 19, 2018
1 parent cb231bc commit 87bed33
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/extension/VSProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,8 @@ private void LoadMSBuildProject()
else
assemblyName = assemblyName + ".dll";

string commonOutputPath = null;
string commonOutputPath = null;
var explicitOutputPaths = new Dictionary<string, string>();

foreach (XmlElement configNode in nodes)
{
Expand All @@ -377,9 +378,12 @@ private void LoadMSBuildProject()
commonOutputPath = outputPath;
continue;
}

if (outputPathElement != null)
explicitOutputPaths[name] = outputPath;

if (outputPath == null)
outputPath = commonOutputPath;
outputPath = explicitOutputPaths.ContainsKey(name) ? explicitOutputPaths[name] : commonOutputPath;

if (outputPath != null)
_configs[name] = new ProjectConfig(this, name, outputPath.Replace("$(Configuration)", name), assemblyName);
Expand Down
8 changes: 7 additions & 1 deletion src/tests/VisualStudioProjectLoaderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -333,13 +333,19 @@ public void ProjectWithDuplicatedSections()
using (var file = new TestResource("test-duplicated-key-project.csproj", NormalizePath(@"csharp-sample\csharp-sample.csproj")))
{
IProject project = _loader.LoadFrom(file.Path);
Assert.AreEqual(2, project.ConfigNames.Count);
Assert.AreEqual(3, project.ConfigNames.Count);

var debugPackage = project.GetTestPackage("Debug");
Assert.AreEqual(1, debugPackage.SubPackages.Count, "Debug should have 1 assembly");

var releasePackage = project.GetTestPackage("Release");
Assert.AreEqual(1, releasePackage.SubPackages.Count, "Release should have 1 assembly");

var secondDebugPackage = project.GetTestPackage("Debug2ndTest");
Assert.AreEqual(1, secondDebugPackage.SubPackages.Count, "Debug2ndTest should have 1 assembly");
Assert.AreEqual(1, secondDebugPackage.SubPackages.Count, "Debug2ndTest should have 1 assemblies");
Assert.That(secondDebugPackage.SubPackages[0].FullName, Does.EndWith(NormalizePath(@"\csharp-sample\Debug2ndTest\SecondTest\Test.exe")),
"Invalid Debug2ndTest assembly path");
}
}

Expand Down
11 changes: 10 additions & 1 deletion src/tests/resources/test-duplicated-key-project.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,13 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release' ">
<DefineConstants>TRACE;RELEASE</DefineConstants>
</PropertyGroup>
</Project>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug2ndTest' ">
<OutputPath>$(Configuration)\SecondTest\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug2ndTest' ">
<Optimize>False</Optimize>
<DebugSymbols>true</DebugSymbols>
<DebugType>Full</DebugType>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
</PropertyGroup>
</Project>

0 comments on commit 87bed33

Please sign in to comment.