Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
2ea0569
Support artifacts output format
dsplaisted Dec 16, 2022
812f8a5
Update tests for artifacts output format
dsplaisted Dec 16, 2022
0d8ed7f
Update publish tests for new output path format
dsplaisted Jan 6, 2023
05aba59
Revert removing TargetFramework from calls to GetOutputDirectory
dsplaisted Jan 6, 2023
dc4f379
Fix package output path, don't check if TargetFramework is a global p…
dsplaisted Jan 10, 2023
046986d
Fix handling of RuntimeIdentifier for blazor wasm and artifacts output
dsplaisted Jan 11, 2023
0d3fe14
Fix tests
dsplaisted Jan 11, 2023
09a2541
Update blazor wasm baselines
dsplaisted Jan 11, 2023
1145160
Update tests
dsplaisted Jan 11, 2023
0d117bf
Update tests
dsplaisted Jan 12, 2023
27ae9eb
Fix tests
dsplaisted Jan 12, 2023
c5be0db
Fix test
dsplaisted Jan 12, 2023
2462691
Switch from artifacts to bin folder for new format, rename properties
dsplaisted Jan 27, 2023
9b0dcd2
Add support for RootOutputPath
dsplaisted Jan 27, 2023
63df854
Don't default to standard output paths based on target framework
dsplaisted Jan 27, 2023
dca2d3a
Revert blazor wasm baseline update
dsplaisted Jan 31, 2023
31e613d
Fix tests
dsplaisted Jan 31, 2023
f7de61d
Fix tests
dsplaisted Jan 31, 2023
29d3685
Fix path casing in test
dsplaisted Jan 31, 2023
c4e3545
Update to latest version of output path design proposal
dsplaisted Feb 24, 2023
aac09cc
Update Artifacts output tests
dsplaisted Feb 28, 2023
b07165d
Fix test code null reference
dsplaisted Feb 28, 2023
2026b9a
Fix test issues
dsplaisted Mar 1, 2023
fc0cb10
Fix tests
dsplaisted Mar 1, 2023
81bf80e
Fix publish path calculation for tests
dsplaisted Mar 1, 2023
06fe5ab
Implement rest of design, fix bugs, add tests
dsplaisted Mar 9, 2023
de35c57
Apply feedback, fix bugs, add test
dsplaisted Mar 9, 2023
3a9f255
Merge branch 'release/8.0.1xx-preview3' into artifacts-output-paths
marcpopMSFT Mar 21, 2023
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
Prev Previous commit
Next Next commit
Fix package output path, don't check if TargetFramework is a global p…
…roperty, and reenable pack tests
  • Loading branch information
dsplaisted committed Mar 21, 2023
commit dc4f379451e60932b7bb34af5e77cb8d69e41e8c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Copyright (c) .NET Foundation. All rights reserved.
<!-- Set the package output path (for nuget pack target) now, before the TargetFramework is appended -->
<PropertyGroup Condition="'$(PackageOutputPath)' == ''">
<PackageOutputPath Condition="'$(UseArtifactsOutput)' != 'true'">$(OutputPath)</PackageOutputPath>
<PackageOutputPath Condition="'$(UseArtifactsOutput)' == 'true'">$(BaseArtifactsPath)\package\</PackageOutputPath>
<PackageOutputPath Condition="'$(UseArtifactsOutput)' == 'true'">$(BaseArtifactsPath)\package\$(Configuration.ToLowerInvariant())\</PackageOutputPath>
</PropertyGroup>

<!-- Exclude files from OutputPath and IntermediateOutputPath from default item globs. Use the value
Expand Down Expand Up @@ -100,15 +100,11 @@ Copyright (c) .NET Foundation. All rights reserved.
<PropertyGroup Condition="'$(UseArtifactsOutput)' == 'true'">
<_ArtifactPivots>$(Configuration.ToLowerInvariant())</_ArtifactPivots>

<!-- Check if TargetFramework is a global property by trying to overwrite it -->
<_TargetFrameworkBackup>$(TargetFramework)</_TargetFrameworkBackup>
<TargetFramework></TargetFramework>
<TargetFrameworkIsGlobal>false</TargetFrameworkIsGlobal>
<TargetFrameworkIsGlobal Condition="'$(TargetFramework)' == '$(_TargetFrameworkBackup)'">true</TargetFrameworkIsGlobal>
<TargetFramework>$(_TargetFrameworkBackup)</TargetFramework>

<_ArtifactPivots Condition="'$(TargetFrameworks)' != '' Or
'$(TargetFrameworkIsGlobal)' == 'true'"
<!-- Per the design, we should include the TargetFramework in the pivots if TargetFrameworks is defined, or if TargetFramework is a global property.
However, basing this on whether TargetFramework is a global property currently breaks "dotnet pack": https://github.com/NuGet/Home/issues/12323
Because of this, for now we will only include the TargetFramework in the pivots if TargetFrameworks is defined, and won't look at whether
TargetFramework is a global property or not. -->
<_ArtifactPivots Condition="'$(TargetFrameworks)' != ''"
>$(_ArtifactPivots)_$(TargetFramework.ToLowerInvariant())</_ArtifactPivots>

<!-- This targets file is evaluated before RuntimeIdentifierInference.targets, so this will only include the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ public void TransitiveFrameworkReferenceFromProjectReference()
runtimeFrameworkNames.Should().BeEquivalentTo("Microsoft.AspNetCore.App", "Microsoft.NETCore.App");
}

[Fact(Skip = "https://github.com/NuGet/Home/issues/12323")]
[Fact]
public void TransitiveFrameworkReferenceFromPackageReference()
{
var referencedPackage = new TestProject()
Expand All @@ -724,13 +724,13 @@ public void TransitiveFrameworkReferenceFromPackageReference()

var packageAsset = _testAssetsManager.CreateTestProject(referencedPackage);

var packCommand = new PackCommand(Log, packageAsset.TestRoot, referencedPackage.Name);
var packCommand = new PackCommand(packageAsset);

packCommand.Execute()
.Should()
.Pass();

var nupkgFolder = packCommand.GetOutputDirectory(null);
var nupkgFolder = packCommand.GetPackageDirectory();

var testProject = new TestProject()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class GivenThatWeHaveAPackageReferenceWithAliases : SdkTest
public GivenThatWeHaveAPackageReferenceWithAliases(ITestOutputHelper log) : base(log)
{ }

[RequiresMSBuildVersionFact("16.8.0", Skip = "https://github.com/NuGet/Home/issues/12323")]
[RequiresMSBuildVersionFact("16.8.0")]
public void CanBuildProjectWithPackageReferencesWithConflictingTypes()
{
var targetFramework = ToolsetInfo.CurrentTargetFramework;
Expand Down Expand Up @@ -61,7 +61,7 @@ public void CanBuildProjectWithPackageReferencesWithConflictingTypes()
.Pass();
}

[RequiresMSBuildVersionFact("16.8.0", Skip = "https://github.com/NuGet/Home/issues/12323")]
[RequiresMSBuildVersionFact("16.8.0")]
public void CanBuildProjectWithMultiplePackageReferencesWithAliases()
{
var targetFramework = ToolsetInfo.CurrentTargetFramework;
Expand Down Expand Up @@ -105,7 +105,7 @@ public void CanBuildProjectWithMultiplePackageReferencesWithAliases()
.Pass();
}

[RequiresMSBuildVersionFact("16.8.0", Skip = "https://github.com/NuGet/Home/issues/12323")]
[RequiresMSBuildVersionFact("16.8.0")]
public void CanBuildProjectWithAPackageReferenceWithMultipleAliases()
{
var targetFramework = ToolsetInfo.CurrentTargetFramework;
Expand Down Expand Up @@ -154,7 +154,7 @@ private IEnumerable<TestPackageReference> GetPackageReferencesWithConflictingTyp
private TestPackageReference GetPackageReference(string targetFramework, string packageName, string projectFileContent, [CallerMemberName] string callingMethod = "", string identifier = null)
{
var project = GetProject(targetFramework, packageName, projectFileContent);
var packCommand = new PackCommand(Log, _testAssetsManager.CreateTestProject(project, callingMethod: callingMethod, identifier: identifier).TestRoot, packageName);
var packCommand = new PackCommand(_testAssetsManager.CreateTestProject(project, callingMethod: callingMethod, identifier: identifier));

packCommand
.Execute()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class GivenThatWeHaveAPpContentFile : SdkTest
public GivenThatWeHaveAPpContentFile(ITestOutputHelper log) : base(log)
{}

[Fact(Skip = "https://github.com/NuGet/Home/issues/12323")]
[Fact]
public void It_copies_to_output_successfully()
{
var packageReference = GetPackageReference();
Expand All @@ -41,7 +41,7 @@ public void It_copies_to_output_successfully()
.Should()
.Pass();

var outputPath = Path.Combine(testAsset.TestRoot, testProject.Name, "bin", "Debug", testProject.TargetFrameworks);
var outputPath = buildCommand.GetOutputDirectory().FullName;
File.Exists(Path.Combine(outputPath, packageReference.ID + ".dll")).Should().BeTrue();
File.Exists(Path.Combine(outputPath, "Nontransformed.ps1")).Should().BeTrue();
File.Exists(Path.Combine(outputPath, "Test.ps1")).Should().BeTrue();
Expand All @@ -61,7 +61,7 @@ private TestPackageReference GetPackageReference()
packageAsset = packageAsset
.WithProjectChanges(project => AddContent(project));

var packCommand = new PackCommand(Log, packageAsset.TestRoot, referencedPackage.Name);
var packCommand = new PackCommand(packageAsset);
packCommand.Execute()
.Should()
.Pass();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,26 @@ public void It_packs_successfully()
.CopyTestAsset("HelloWorld")
.WithSource();

new PackCommand(Log, testAsset.TestRoot)
var packCommand = new PackCommand(testAsset);

packCommand
.Execute()
.Should()
.Pass();


var packageDirectory = packCommand.GetPackageDirectory();
packageDirectory.Should().OnlyHaveFiles(new[]
{
"HelloWorld.1.0.0.nupkg",
});

var outputDirectory = new DirectoryInfo(Path.Combine(testAsset.TestRoot, "bin", "Debug"));
var outputDirectory = packCommand.GetOutputDirectory();
outputDirectory.Should().OnlyHaveFiles(new[] {
"HelloWorld.1.0.0.nupkg",
$"{ToolsetInfo.CurrentTargetFramework}/HelloWorld.dll",
$"{ToolsetInfo.CurrentTargetFramework}/HelloWorld.pdb",
$"{ToolsetInfo.CurrentTargetFramework}/HelloWorld.deps.json",
$"{ToolsetInfo.CurrentTargetFramework}/HelloWorld.runtimeconfig.json",
$"{ToolsetInfo.CurrentTargetFramework}/HelloWorld{EnvironmentInfo.ExecutableExtension}",
$"HelloWorld.dll",
$"HelloWorld.pdb",
$"HelloWorld.deps.json",
$"HelloWorld.runtimeconfig.json",
$"HelloWorld{EnvironmentInfo.ExecutableExtension}",
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public GivenThatWeWantToPublishWithGeneratePackageOnBuildAndPackAsTool(ITestOutp
[Theory]
[InlineData(false, false)]
[InlineData(false, true)]
[InlineData(true, false, Skip = "https://github.com/NuGet/Home/issues/12323")]
[InlineData(true, true, Skip = "https://github.com/NuGet/Home/issues/12323")]
[InlineData(true, false)]
[InlineData(true, true)]
public void It_publishes_successfully(bool generatePackageOnBuild, bool packAsTool)
{
Console.WriteLine(generatePackageOnBuild.ToString() + packAsTool.ToString());
Expand All @@ -54,8 +54,8 @@ public void It_publishes_successfully(bool generatePackageOnBuild, bool packAsTo
[Theory]
[InlineData(false, false)]
[InlineData(false, true)]
[InlineData(true, false, Skip = "https://github.com/NuGet/Home/issues/12323")]
[InlineData(true, true, Skip = "https://github.com/NuGet/Home/issues/12323")]
[InlineData(true, false)]
[InlineData(true, true)]
public void It_builds_with_GeneratePackageOnBuild_successfully(bool generatePackageOnBuild, bool packAsTool)
{
TestAsset testAsset = _testAssetsManager
Expand Down
11 changes: 11 additions & 0 deletions src/Tests/Microsoft.NET.TestFramework/Commands/MSBuildCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,17 @@ public virtual DirectoryInfo GetIntermediateDirectory(string targetFramework = "
return new DirectoryInfo(output);
}

public DirectoryInfo GetPackageDirectory(string configuration = "Debug")
{
if (TestAsset != null)
{
return new DirectoryInfo(OutputPathCalculator.FromTestAsset(ProjectFile, TestAsset).GetPackageDirectory(configuration));
}

string output = Path.Combine(ProjectRootPath, "bin", configuration);
return new DirectoryInfo(output);
}

public virtual DirectoryInfo GetNonSDKOutputDirectory(string configuration = "Debug")
{
configuration = configuration ?? string.Empty;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ public sealed class PackCommand : MSBuildCommand
public PackCommand(ITestOutputHelper log, string projectPath, string relativePathToProject = null)
: base(log, "Pack", projectPath, relativePathToProject)
{

}

public PackCommand(TestAsset testAsset, string relativePathToProject = null)
: base(testAsset, "Pack", relativePathToProject)
{

}

public string GetIntermediateNuspecPath(string packageId = null, string configuration = "Debug", string packageVersion = "1.0.0")
Expand All @@ -30,7 +37,7 @@ public string GetNuGetPackage(string packageId = null, string configuration = "D
packageId = Path.GetFileNameWithoutExtension(ProjectFile);
}

return Path.Combine(GetOutputDirectory(null, configuration).FullName, $"{packageId}.{packageVersion}.nupkg");
return Path.Combine(GetPackageDirectory(configuration).FullName, $"{packageId}.{packageVersion}.nupkg");
}
}
}
12 changes: 12 additions & 0 deletions src/Tests/Microsoft.NET.TestFramework/OutputPathCalculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,5 +195,17 @@ public string GetIntermediateDirectory(string targetFramework = null, string con
string output = System.IO.Path.Combine(Path.GetDirectoryName(ProjectPath), "obj", configuration, targetFramework, runtimeIdentifier);
return output;
}

public string GetPackageDirectory(string configuration = "Debug")
{
if (UsesArtifactsFolder())
{
return System.IO.Path.Combine(Path.GetDirectoryName(ProjectPath), "artifacts", "package", configuration.ToLowerInvariant());
}
else
{
return System.IO.Path.Combine(Path.GetDirectoryName(ProjectPath), "bin", configuration);
}
}
}
}