Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Honor AppendTargetFrameworkToOutputPath set to false #46

Merged
merged 1 commit into from
Sep 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions cake/package-tests.cake
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,26 @@ public abstract class PackageTester
_parameters = parameters;
_context = parameters.Context;

// TODO: Re-enable when issue #38 and general support of the
// new SDK format are complete.
// PackageTests.Add(new PackageTest()
// {
// Description = "Re-run unit tests using csproj file",
// Arguments = $"src/tests/vs-project-loader.tests.csproj --config={_parameters.Configuration}",
// TestConsoleVersions = new string[] { "3.7.0" },
// ExpectedResult = new ExpectedResult("Failed")
// {
// Total = 65,
// Passed = 65,
// Failed = 0,
// Warnings = 0,
// Inconclusive = 0,
// Skipped = 0,
// Assemblies = new[] { new ExpectedAssemblyResult("vs-project-loader.tests.dll", "net-2.0") }
// }
// });
}
// TODO: Re-enable when issue #38 and general support of the
// new SDK format are complete.

PackageTests.Add(new PackageTest()
{
Description = "Re-run unit tests using csproj file",
Arguments = $"src/tests/vs-project-loader.tests.csproj --config={_parameters.Configuration}",
TestConsoleVersions = new string[] { "3.7.0" },
ExpectedResult = new ExpectedResult("Passed")
{
Total = 69,
Passed = 69,
Failed = 0,
Warnings = 0,
Inconclusive = 0,
Skipped = 0,
Assemblies = new[] { new ExpectedAssemblyResult("vs-project-loader.tests.dll", "net-2.0") }
}
});
}

protected abstract string PackageName { get; }
protected abstract string PackageUnderTest { get; }
Expand Down
26 changes: 17 additions & 9 deletions src/extension/VSProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ private void Load()
case ".csproj":
// We try legacy project first, then new format for .NET Core projects
if (!TryLoadLegacyProject())
if (!TryLoadDotNetCoreProject())
if (!TryLoadSdkProject())
LoadMSBuildProject();
break;

Expand Down Expand Up @@ -238,11 +238,11 @@ private void Load()
}

/// <summary>
/// Load a project in the new project format for .NET Core 1.0/1.1. Note that this method
/// Load a project in the SDK project format. Note that this method
/// is only called for file extensions .csproj.
/// </summary>
/// <returns>True if the project was successfully loaded, false otherwise.</returns>
private bool TryLoadDotNetCoreProject()
private bool TryLoadSdkProject()
{
XmlNode root = _doc.SelectSingleNode("Project");

Expand All @@ -251,7 +251,7 @@ private bool TryLoadDotNetCoreProject()
string targetFramework = _doc.SelectSingleNode("Project/PropertyGroup/TargetFramework").InnerText;

XmlNode assemblyNameNode = _doc.SelectSingleNode("Project/PropertyGroup/AssemblyName");

// Even console apps are dll's even if <OutputType> has value 'EXE',
// if TargetFramework is netcore
string outputType = "dll";
Expand Down Expand Up @@ -279,6 +279,9 @@ private bool TryLoadDotNetCoreProject()

string assemblyName = assemblyNameNode == null ? $"{Name}.{outputType}" : $"{assemblyNameNode.InnerText}.{outputType}";

var appendTargetFrameworkNode = _doc.SelectSingleNode("Project/PropertyGroup/AppendTargetFrameworkToOutputPath");
bool appendTargetFramework = appendTargetFrameworkNode == null || appendTargetFrameworkNode.InnerText.ToLower() == "true";

XmlNodeList nodes = _doc.SelectNodes("/Project/PropertyGroup");

string commonOutputPath = null;
Expand All @@ -298,9 +301,6 @@ private bool TryLoadDotNetCoreProject()
continue;
}

if (outputPath == null)
outputPath = commonOutputPath;

if (outputPath != null)
_configs.Add(configName, new ProjectConfig(this, configName, outputPath, assemblyName));
}
Expand All @@ -314,13 +314,21 @@ private bool TryLoadDotNetCoreProject()
if (!_configs.ContainsKey("Debug"))
{
string configName = "Debug";
string outputPath = $@"bin\{configName}\{targetFramework}";
string outputPath = commonOutputPath != null
? commonOutputPath.Replace("$(Configuration)", configName)
: $@"bin\{configName}";
if (appendTargetFramework)
outputPath += "/" + targetFramework;
_configs.Add(configName, new ProjectConfig(this, configName, outputPath, assemblyName));
}
if (!_configs.ContainsKey("Release"))
{
string configName = "Release";
string outputPath = $@"bin\{configName}\{targetFramework}";
string outputPath = commonOutputPath != null
? commonOutputPath.Replace("$(Configuration)", configName)
: $@"bin\{configName}";
if (appendTargetFramework)
outputPath += "/" + targetFramework;
_configs.Add(configName, new ProjectConfig(this, configName, outputPath, assemblyName));
}
}
Expand Down
Loading