Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -503,16 +503,13 @@ ImmutableArray<CSharpDirective> DeduplicateSdkDirectives(ImmutableArray<CSharpDi

lastProject = (projectFileText, project, projectRoot);

// Preserve the legacy artifacts behavior when the .NET SDK imported its artifacts props but selected no layout.
// Preserve the legacy artifacts behavior when the .NET SDK imported its artifacts props but does not support FileBasedAppArtifactsPath.
// dotnet CLI has the latest SDK imported but other hosts like MSBuildWorkspace may not.
if (_useLegacyArtifactsPath is null)
{
var defaultArtifactsPathPropsImported = await project.GetPropertyValueAsync("_DefaultArtifactsPathPropsImported").ConfigureAwait(false);
var artifactsPathLocationType = await project.GetPropertyValueAsync("_ArtifactsPathLocationType").ConfigureAwait(false);
var supportsFileBasedAppArtifactsPath = await project.GetPropertyValueAsync("_SupportsFileBasedAppArtifactsPath").ConfigureAwait(false);

_useLegacyArtifactsPath =
string.Equals(defaultArtifactsPathPropsImported, bool.TrueString, StringComparison.OrdinalIgnoreCase) &&
string.IsNullOrEmpty(artifactsPathLocationType);
_useLegacyArtifactsPath = !string.Equals(supportsFileBasedAppArtifactsPath, bool.TrueString, StringComparison.OrdinalIgnoreCase);

if (_useLegacyArtifactsPath == true)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Copyright (c) .NET Foundation. All rights reserved.
Set a property to indicate it was imported, so we can avoid a duplicate import. -->
<PropertyGroup>
<_DefaultArtifactsPathPropsImported>true</_DefaultArtifactsPathPropsImported>
<_SupportsFileBasedAppArtifactsPath>true</_SupportsFileBasedAppArtifactsPath>
</PropertyGroup>

<!-- Setting ArtifactsPath automatically opts in to the artifacts output format -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1861,14 +1861,9 @@ public class LibClass
(await result.Project.GetPropertyValueAsync("TargetFramework")).Should().Be(ToolsetInfo.CurrentTargetFramework);
}

[TestMethod]
[DataRow(true, "", true)]
[DataRow(true, "FileBasedApp", false)]
[DataRow(false, "", false)]
[TestMethod, CombinatorialData]
public async Task Api_VirtualProjectBuilder_ArtifactsPathCompatibility(
bool defaultArtifactsPathPropsImported,
string artifactsPathLocationType,
bool expectLegacyArtifactsPath)
bool supportsFileBasedAppArtifactsPath)
{
var testInstance = TestAssetsManager.CreateTestDirectory();
var programPath = Path.Join(testInstance.Path, "Program.cs");
Expand All @@ -1887,14 +1882,13 @@ public async Task Api_VirtualProjectBuilder_ArtifactsPathCompatibility(
VirtualProjectBuildingCommand.ThrowingReporter,
additionalGlobalProperties: new Dictionary<string, string>
{
["_DefaultArtifactsPathPropsImported"] = defaultArtifactsPathPropsImported.ToString(),
["_ArtifactsPathLocationType"] = artifactsPathLocationType,
["_SupportsFileBasedAppArtifactsPath"] = supportsFileBasedAppArtifactsPath.ToString(),
Comment thread
jjonescz marked this conversation as resolved.
});

var xml = result.ProjectRootElement.GetRawXml();
Log.WriteLine(xml);

if (expectLegacyArtifactsPath)
if (!supportsFileBasedAppArtifactsPath)
{
xml.Should()
.Contain("<IncludeProjectNameInArtifactsPaths>false</IncludeProjectNameInArtifactsPaths>")
Expand Down
Loading