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
Update publish tests for new output path format
  • Loading branch information
dsplaisted committed Mar 21, 2023
commit 0d8ed7fa1ddce19879aae19e68b61e9221001cde
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,15 @@ public void It_publishes_with_or_without_apphost(string useAppHost, string targe

var testAsset = _testAssetsManager
.CopyTestAsset(TestProjectName, $"It_publishes_with_or_without_apphost_{(useAppHost ?? "null")}_{targetFramework}")
.WithTargetFramework(targetFramework)
.WithSource();

var msbuildArgs = new List<string>()
{
$"/p:RuntimeIdentifier={runtimeIdentifier}",
$"/p:TestRuntimeIdentifier={runtimeIdentifier}",
"/p:SelfContained=false",
$"/p:TargetFramework={targetFramework}"
//$"/p:TargetFramework={targetFramework}"
};

if (useAppHost != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void It_publishes_portable_apps_to_the_publish_folder_and_the_app_should_
publishResult.Should().Pass();

var publishDirectory = publishCommand.GetOutputDirectory(targetFramework);
var outputDirectory = publishDirectory.Parent;
var outputDirectory = new BuildCommand(helloWorldAsset).GetOutputDirectory(targetFramework);

var filesPublished = new[] {
"HelloWorld.dll",
Expand Down Expand Up @@ -104,7 +104,7 @@ public void It_publishes_self_contained_apps_to_the_publish_folder_and_the_app_s
var publishDirectory = publishCommand.GetOutputDirectory(
targetFramework: targetFramework,
runtimeIdentifier: rid);
var outputDirectory = publishDirectory.Parent;
var outputDirectory = new BuildCommand(helloWorldAsset).GetOutputDirectory(targetFramework, runtimeIdentifier: rid);
var selfContainedExecutable = $"HelloWorld{Constants.ExeSuffix}";

var filesPublished = new[] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public void It_publishes_documentation_files(string properties, bool expectAppDo
.CopyTestAsset("KitchenSink", identifier: $"{expectAppDocPublished}_{expectLibProjectDocPublished}")
.WithSource();

var publishCommand = new PublishCommand(Log, Path.Combine(kitchenSinkAsset.TestRoot, "TestApp"));
var publishCommand = new PublishCommand(kitchenSinkAsset, "TestApp");
var publishArgs = properties.Split(';').Select(p => $"/p:{p}").ToArray();
var publishResult = publishCommand.Execute(publishArgs);

Expand Down Expand Up @@ -269,10 +269,9 @@ public void It_publishes_referenced_assembly_documentation(string property, bool
};

var appAsset = _testAssetsManager.CreateTestProject(appProject, identifier: identifier);
var appSourcePath = Path.Combine(appAsset.TestRoot, "TestApp");

new RestoreCommand(appAsset, "TestApp").Execute().Should().Pass();
var appPublishCommand = new PublishCommand(Log, appSourcePath);
var appPublishCommand = new PublishCommand(appAsset);
var appPublishResult = appPublishCommand.Execute("/p:" + property);
appPublishResult.Should().Pass();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void NativeAot_hw_runs_with_no_warnings_when_PublishAot_is_enabled(string
}
var testAsset = _testAssetsManager.CreateTestProject(testProject);

var publishCommand = new PublishCommand(Log, Path.Combine(testAsset.TestRoot, testProject.Name));
var publishCommand = new PublishCommand(testAsset);
publishCommand
.Execute($"/p:UseCurrentRuntimeIdentifier=true")
.Should().Pass()
Expand Down Expand Up @@ -96,7 +96,7 @@ public void NativeAot_hw_runs_with_no_warnings_when_PublishAot_is_false(string t
testProject.AdditionalProperties["PublishAot"] = "false";
var testAsset = _testAssetsManager.CreateTestProject(testProject);

var publishCommand = new PublishCommand(Log, Path.Combine(testAsset.TestRoot, testProject.Name));
var publishCommand = new PublishCommand(testAsset);
publishCommand
.Execute($"/p:RuntimeIdentifier={rid}")
.Should().Pass()
Expand Down Expand Up @@ -144,7 +144,7 @@ public void NativeAot_app_runs_in_debug_with_no_config_when_PublishAot_is_enable
// <RuntimeHostConfigurationOption Include="key1" Value="value1" />
.WithProjectChanges(project => AddRuntimeConfigOption(project));

var publishCommand = new PublishCommand(Log, Path.Combine(testAsset.TestRoot, testProject.Name));
var publishCommand = new PublishCommand(testAsset);
publishCommand
.Execute($"/p:UseCurrentRuntimeIdentifier=true")
.Should().Pass();
Expand Down Expand Up @@ -202,7 +202,7 @@ public void NativeAot_app_runs_in_release_with_no_config_when_PublishAot_is_enab
// <RuntimeHostConfigurationOption Include="key1" Value="value1" />
.WithProjectChanges(project => AddRuntimeConfigOption(project));

var publishCommand = new PublishCommand(Log, Path.Combine(testAsset.TestRoot, testProject.Name));
var publishCommand = new PublishCommand(testAsset);
publishCommand
.Execute($"/p:UseCurrentRuntimeIdentifier=true")
.Should().Pass();
Expand Down Expand Up @@ -294,7 +294,7 @@ public void NativeAot_hw_runs_with_PackageReference_PublishAot_is_enabled(string
}
var testAsset = _testAssetsManager.CreateTestProject(testProject);

var publishCommand= new PublishCommand(Log, Path.Combine(testAsset.TestRoot, testProject.Name));
var publishCommand = new PublishCommand(testAsset);
publishCommand
.Execute($"/p:UseCurrentRuntimeIdentifier=true")
.Should().Pass()
Expand Down Expand Up @@ -348,7 +348,7 @@ public void NativeAot_hw_runs_with_PackageReference_PublishAot_is_empty(string t
}
var testAsset = _testAssetsManager.CreateTestProject(testProject);

var publishCommand = new PublishCommand(Log, Path.Combine(testAsset.TestRoot, testProject.Name));
var publishCommand = new PublishCommand(testAsset);
publishCommand
.Execute($"/p:RuntimeIdentifier={rid}")
.Should().Pass();
Expand Down Expand Up @@ -380,7 +380,7 @@ public void NativeAot_hw_runs_with_cross_target_PublishAot_is_enabled(string tar

var testAsset = _testAssetsManager.CreateTestProject(testProject);

var publishCommand = new PublishCommand(Log, Path.Combine(testAsset.TestRoot, testProject.Name));
var publishCommand = new PublishCommand(testAsset);
publishCommand
.Execute($"/p:RuntimeIdentifier={rid}")
.Should().Pass();
Expand Down Expand Up @@ -411,7 +411,7 @@ public void NativeAot_hw_runs_with_cross_PackageReference_PublishAot_is_enabled(

var testAsset = _testAssetsManager.CreateTestProject(testProject);

var publishCommand = new PublishCommand(Log, Path.Combine(testAsset.TestRoot, testProject.Name));
var publishCommand = new PublishCommand(testAsset);
publishCommand
.Execute($"/p:RuntimeIdentifier={rid}")
.Should().Pass()
Expand Down Expand Up @@ -446,7 +446,7 @@ public void NativeAot_hw_runs_with_cross_PackageReference_PublishAot_is_empty(st

var testAsset = _testAssetsManager.CreateTestProject(testProject);

var publishCommand = new PublishCommand(Log, Path.Combine(testAsset.TestRoot, testProject.Name));
var publishCommand = new PublishCommand(testAsset);
publishCommand
.Execute($"/p:RuntimeIdentifier={rid}")
.Should().Pass();
Expand Down Expand Up @@ -569,7 +569,7 @@ public void NativeAot_compiler_runs_when_PublishAot_is_enabled(string targetFram
testProject.AdditionalProperties["UseCurrentRuntimeIdentifier"] = "true";
var testAsset = _testAssetsManager.CreateTestProject(testProject);

var publishCommand = new PublishCommand(Log, Path.Combine(testAsset.TestRoot, testProject.Name));
var publishCommand = new PublishCommand(testAsset);
publishCommand
.Execute()
.Should().Pass()
Expand Down Expand Up @@ -614,7 +614,7 @@ public void Warnings_are_generated_even_with_analyzers_disabled(string targetFra
testProject.AdditionalProperties["UseCurrentRuntimeIdentifier"] = "true";
var testAsset = _testAssetsManager.CreateTestProject(testProject);

var publishCommand = new PublishCommand(Log, Path.Combine(testAsset.TestRoot, testProject.Name));
var publishCommand = new PublishCommand(testAsset);
publishCommand
.Execute()
.Should().Pass()
Expand Down Expand Up @@ -653,7 +653,7 @@ public void NativeAotStaticLib_only_runs_when_switch_is_enabled(string targetFra
testProject.AdditionalProperties["SelfContained"] = "true";
var testAsset = _testAssetsManager.CreateTestProject(testProject);

var publishCommand = new PublishCommand(Log, Path.Combine(testAsset.TestRoot, testProject.Name));
var publishCommand = new PublishCommand(testAsset);
publishCommand
.Execute()
.Should().Pass();
Expand Down Expand Up @@ -686,7 +686,7 @@ public void NativeAotSharedLib_only_runs_when_switch_is_enabled(string targetFra
testProject.AdditionalProperties["SelfContained"] = "true";
var testAsset = _testAssetsManager.CreateTestProject(testProject);

var publishCommand = new PublishCommand(Log, Path.Combine(testAsset.TestRoot, testProject.Name));
var publishCommand = new PublishCommand(testAsset);
publishCommand
.Execute()
.Should().Pass();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ private void PublishAppWithLibraryAndRid(bool selfContained, out DirectoryInfo p
.CopyTestAsset("AppWithLibraryAndRid", $"PublishAppWithLibraryAndRid{selfContained}")
.WithSource();

var projectPath = Path.Combine(testAsset.TestRoot, "App");

var msbuildArgs = new List<string>()
{
$"/p:RuntimeIdentifier={runtimeIdentifier}",
Expand All @@ -116,7 +114,7 @@ private void PublishAppWithLibraryAndRid(bool selfContained, out DirectoryInfo p
.Should()
.Pass();

var publishCommand = new PublishCommand(Log, projectPath);
var publishCommand = new PublishCommand(testAsset, "App");

publishCommand
.Execute(msbuildArgs.ToArray())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,27 @@ public void It_cleans_before_single_file_publish()
};
var testAsset = _testAssetsManager.CreateTestProject(testProject, testProject.Name);

var publishDir = Path.Combine(testAsset.TestRoot, testProject.Name, "bin", "Debug", testProject.TargetFrameworks, testProject.RuntimeIdentifier, "publish");
var expectedNonSingleExeFiles = new string[] { ".dll", ".deps.json", ".runtimeconfig.json" }
.Select(ending => testProject.Name + ending);
var expectedSingleExeFiles = new string[] { ".exe", ".pdb" }.Select(ending => testProject.Name + ending);


// Publish normally
new PublishCommand(testAsset)
var publishCommand = new PublishCommand(testAsset);

publishCommand
.Execute()
.Should()
.Pass();

var publishDir = publishCommand.GetOutputDirectory().FullName;
var expectedNonSingleExeFiles = new string[] { ".dll", ".deps.json", ".runtimeconfig.json" }
.Select(ending => testProject.Name + ending);
var expectedSingleExeFiles = new string[] { ".exe", ".pdb" }.Select(ending => testProject.Name + ending);

CheckPublishOutput(publishDir, expectedSingleExeFiles.Concat(expectedNonSingleExeFiles), null);

File.WriteAllText(Path.Combine(publishDir, "UserData.txt"), string.Empty);

// Publish as a single file
new PublishCommand(testAsset)
publishCommand
.Execute(@"/p:PublishSingleFile=true")
.Should()
.Pass();
Expand All @@ -66,14 +71,17 @@ public void It_cleans_between_renames()
};
var testAsset = _testAssetsManager.CreateTestProject(testProject, testProject.Name);

var publishDir = Path.Combine(testAsset.TestRoot, testProject.Name, "bin", "Debug", testProject.TargetFrameworks, testProject.RuntimeIdentifier, "publish");
var expectedSingleExeFileExtensions = new string[] { ".exe", ".pdb" };

// Publish as a single file
new PublishCommand(testAsset)
var publishCommand = new PublishCommand(testAsset);
publishCommand
.Execute(@"/p:PublishSingleFile=true")
.Should()
.Pass();

var publishDir = publishCommand.GetOutputDirectory().FullName;
var expectedSingleExeFileExtensions = new string[] { ".exe", ".pdb" };

CheckPublishOutput(publishDir, expectedSingleExeFileExtensions.Select(ending => testProject.Name + ending), null);

File.WriteAllText(Path.Combine(publishDir, "UserData.txt"), string.Empty);
Expand Down Expand Up @@ -105,21 +113,23 @@ public void It_cleans_between_single_file_publishes()
};
var testAsset = _testAssetsManager.CreateTestProject(testProject, testProject.Name);

var publishDir = Path.Combine(testAsset.TestRoot, testProject.Name, "bin", "Debug", testProject.TargetFrameworks, testProject.RuntimeIdentifier, "publish");
var expectedSingleExeFiles = new string[] { ".exe", ".pdb" }.Select(ending => testProject.Name + ending);

// Publish as a single file
new PublishCommand(testAsset)
var publishCommand = new PublishCommand(testAsset);
publishCommand
.Execute(@"/p:PublishSingleFile=true")
.Should()
.Pass();

var publishDir = publishCommand.GetOutputDirectory().FullName;
var expectedSingleExeFiles = new string[] { ".exe", ".pdb" }.Select(ending => testProject.Name + ending);

CheckPublishOutput(publishDir, expectedSingleExeFiles, null);

// Write a file that would have been in a full publish, should still be there after another single file publish
File.WriteAllText(Path.Combine(publishDir, testProject.Name + ".dll"), string.Empty);

// Publish as a single file
new PublishCommand(testAsset)
publishCommand
.Execute(@"/p:PublishSingleFile=true")
.Should()
.Pass();
Expand All @@ -139,22 +149,25 @@ public void It_cleans_before_trimmed_single_file_publish()
testProject.AdditionalProperties["PublishTrimmed"] = "true";
var testAsset = _testAssetsManager.CreateTestProject(testProject, testProject.Name);

var publishDir = Path.Combine(testAsset.TestRoot, testProject.Name, "bin", "Debug", testProject.TargetFrameworks, testProject.RuntimeIdentifier, "publish");
var expectedNonSingleExeFiles = new string[] { ".dll", ".deps.json", ".runtimeconfig.json" }
.Select(ending => testProject.Name + ending);
var expectedSingleExeFiles = new string[] { ".exe", ".pdb" }.Select(ending => testProject.Name + ending);

// Publish trimmed
new PublishCommand(testAsset)
var publishCommand = new PublishCommand(testAsset);

publishCommand
.Execute()
.Should()
.Pass();

var publishDir = publishCommand.GetOutputDirectory().FullName;
var expectedNonSingleExeFiles = new string[] { ".dll", ".deps.json", ".runtimeconfig.json" }
.Select(ending => testProject.Name + ending);
var expectedSingleExeFiles = new string[] { ".exe", ".pdb" }.Select(ending => testProject.Name + ending);

CheckPublishOutput(publishDir, expectedSingleExeFiles.Concat(expectedNonSingleExeFiles), null);

File.WriteAllText(Path.Combine(publishDir, "UserData.txt"), string.Empty);

// Publish as a single file
new PublishCommand(testAsset)
publishCommand
.Execute(@"/p:PublishSingleFile=true")
.Should()
.Pass();
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)]
[InlineData(true, true)]
[InlineData(true, false, Skip = "https://github.com/NuGet/Home/issues/12323")]
[InlineData(true, true, Skip = "https://github.com/NuGet/Home/issues/12323")]
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)]
[InlineData(true, true)]
[InlineData(true, false, Skip = "https://github.com/NuGet/Home/issues/12323")]
[InlineData(true, true, Skip = "https://github.com/NuGet/Home/issues/12323")]
public void It_builds_with_GeneratePackageOnBuild_successfully(bool generatePackageOnBuild, bool packAsTool)
{
TestAsset testAsset = _testAssetsManager
Expand Down
4 changes: 2 additions & 2 deletions src/Tests/Microsoft.NET.Publish.Tests/PublishWpfApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ public void It_publishes_and_runs_self_contained_wpf_app()
.Should()
.Pass();

var publishDirectory = publishCommand.GetOutputDirectory(
var publishDirectory = OutputPathCalculator.FromTestAsset(Path.Combine(testDir.Path, Path.GetFileName(testDir.Path) + ".csproj")).GetPublishDirectory(
targetFramework: targetFramework,
runtimeIdentifier: rid);

var runAppCommand = new SdkCommandSpec()
{
FileName = Path.Combine(publishDirectory.FullName, Path.GetFileName(testDir.Path) + ".exe")
FileName = Path.Combine(publishDirectory, Path.GetFileName(testDir.Path) + ".exe")
};

runAppCommand.Environment["DOTNET_ROOT"] = Path.GetDirectoryName(TestContext.Current.ToolsetUnderTest.DotNetHostPath);
Expand Down
Loading