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 tests for artifacts output format
  • Loading branch information
dsplaisted committed Mar 21, 2023
commit 812f8a50aae11ecacfd865932d204833f151acfd
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,6 @@
<PublicSign>true</PublicSign>
</PropertyGroup>

<!--
Also target desktop on Windows to get more test coverage:
* Desktop requires satellites to have same public key as parent whereas coreclr does not.
* Reference path handling of satellite assembly generation used to be incorrect for desktop.
-->
<PropertyGroup Condition="$([MSBuild]::IsOSPlatform(`Windows`))">
<TargetFrameworks>$(TargetFrameworks);net46</TargetFrameworks>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'net46'">
<PublicSign>false</PublicSign>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,6 @@
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>

<!--
Also target desktop on Windows to get more test coverage:
* Desktop requires satellites to have same public key as parent whereas coreclr does not.
* Reference path handling of satellite assembly generation used to be incorrect for desktop.
-->
<PropertyGroup Condition="$([MSBuild]::IsOSPlatform(`Windows`))">
<TargetFrameworks>$(TargetFrameworks);net46</TargetFrameworks>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'net46'">
<PublicSign>false</PublicSign>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" />

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>$(CurrentTargetFramework)</TargetFramework>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" />

<Target Name="CheckPlatform" BeforeTargets="Build">
<Error Condition="'$(Platform)' != 'x64'" Text="This test project expects to be built via solution and have Platform=x64" />
</Target>
Expand Down
10 changes: 5 additions & 5 deletions src/Tests/Microsoft.NET.Build.Tests/AppHostTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void It_builds_a_runnable_apphost_by_default(string targetFramework)
.Should()
.Pass();

var outputDirectory = buildCommand.GetOutputDirectory(targetFramework);
var outputDirectory = buildCommand.GetOutputDirectory();
var hostExecutable = $"HelloWorld{Constants.ExeSuffix}";
outputDirectory.Should().OnlyHaveFiles(GetExpectedFilesFromBuild(testAsset, targetFramework));
new RunExeCommand(Log, Path.Combine(outputDirectory.FullName, hostExecutable))
Expand Down Expand Up @@ -270,19 +270,19 @@ public void It_uses_an_apphost_based_on_platform_target(string target)

var testAsset = _testAssetsManager
.CopyTestAsset("HelloWorld", identifier: target)
.WithTargetFramework(targetFramework)
.WithSource();

var buildCommand = new BuildCommand(testAsset);
buildCommand
.Execute(new string[] {
$"/p:TargetFramework={targetFramework}",
$"/p:PlatformTarget={target}",
$"/p:NETCoreSdkRuntimeIdentifier={EnvironmentInfo.GetCompatibleRid(targetFramework)}"
})
.Should()
.Pass();

var apphostPath = Path.Combine(buildCommand.GetOutputDirectory(targetFramework).FullName, "HelloWorld.exe");
var apphostPath = Path.Combine(buildCommand.GetOutputDirectory().FullName, "HelloWorld.exe");
if (target == "x86")
{
IsPE32(apphostPath).Should().BeTrue();
Expand Down Expand Up @@ -321,7 +321,7 @@ public void AppHost_contains_resources_from_the_managed_dll()
.Should()
.Pass();

var outputDirectory = buildCommand.GetOutputDirectory(targetFramework, runtimeIdentifier: runtimeIdentifier);
var outputDirectory = buildCommand.GetOutputDirectory(runtimeIdentifier: runtimeIdentifier);
outputDirectory.Should().HaveFiles(new[] { testProject.Name + ".exe" });

string apphostPath = Path.Combine(outputDirectory.FullName, testProject.Name + ".exe");
Expand Down Expand Up @@ -406,7 +406,7 @@ public void It_retries_on_failure_to_create_apphost()
.Should()
.Pass();

var intermediateDirectory = buildCommand.GetIntermediateDirectory(targetFramework: ToolsetInfo.CurrentTargetFramework).FullName;
var intermediateDirectory = buildCommand.GetIntermediateDirectory().FullName;

File.SetLastWriteTimeUtc(
Path.Combine(
Expand Down
6 changes: 2 additions & 4 deletions src/Tests/Microsoft.NET.Build.Tests/DepsFileSkipTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@ public void ResourceAssetFromPackageCanBeSkipped()
.Should()
.Pass();

string outputFolder = buildCommand.GetOutputDirectory(testProject.TargetFrameworks,
runtimeIdentifier: testProject.RuntimeIdentifier).FullName;
string outputFolder = buildCommand.GetOutputDirectory(runtimeIdentifier: testProject.RuntimeIdentifier).FullName;

string depsJsonPath = Path.Combine(outputFolder, $"{testProject.Name}.deps.json");

Expand Down Expand Up @@ -178,8 +177,7 @@ private void TestSkippingFile(TestProject testProject, string filenameToSkip, st
.Should()
.Pass();

string outputFolder = buildCommand.GetOutputDirectory(testProject.TargetFrameworks,
runtimeIdentifier: testProject.RuntimeIdentifier).FullName;
string outputFolder = buildCommand.GetOutputDirectory(runtimeIdentifier: testProject.RuntimeIdentifier).FullName;

string depsJsonPath = Path.Combine(outputFolder, $"{testProject.Name}.deps.json");

Expand Down
20 changes: 10 additions & 10 deletions src/Tests/Microsoft.NET.Build.Tests/GivenFrameworkReferences.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void Multiple_frameworks_are_written_to_runtimeconfig_when_there_are_mult
.Should()
.Pass();

var outputDirectory = buildCommand.GetOutputDirectory(testProject.TargetFrameworks);
var outputDirectory = buildCommand.GetOutputDirectory();

string runtimeConfigFile = Path.Combine(outputDirectory.FullName, testProject.Name + ".runtimeconfig.json");
var runtimeFrameworkNames = GetRuntimeFrameworks(runtimeConfigFile);
Expand Down Expand Up @@ -107,9 +107,9 @@ public void Multiple_frameworks_are_written_to_runtimeconfig_for_self_contained_
.Should()
.Pass();

DirectoryInfo outputDirectory = buildCommand.GetOutputDirectory(testProject.TargetFrameworks);
DirectoryInfo outputDirectory = buildCommand.GetOutputDirectory(runtimeIdentifier: testProject.RuntimeIdentifier);

string runtimeConfigFile = Path.Combine(outputDirectory.FullName, testProject.RuntimeIdentifier, testProject.Name + ".runtimeconfig.json");
string runtimeConfigFile = Path.Combine(outputDirectory.FullName, testProject.Name + ".runtimeconfig.json");
List<string> includedFrameworkNames = GetIncludedFrameworks(runtimeConfigFile);
if (shouldHaveIncludedFrameworks)
{
Expand Down Expand Up @@ -173,7 +173,7 @@ public void DuplicateFrameworksAreNotWrittenToRuntimeConfigWhenThereAreDifferent
.Should()
.Pass();

var outputDirectory = buildCommand.GetOutputDirectory(testProject.TargetFrameworks);
var outputDirectory = buildCommand.GetOutputDirectory();

string runtimeConfigFile = Path.Combine(outputDirectory.FullName, testProject.Name + ".runtimeconfig.json");
var runtimeFrameworkNames = GetRuntimeFrameworks(runtimeConfigFile);
Expand Down Expand Up @@ -702,7 +702,7 @@ public void TransitiveFrameworkReferenceFromProjectReference()
.Should()
.Pass();

var outputDirectory = buildCommand.GetOutputDirectory(testProject.TargetFrameworks);
var outputDirectory = buildCommand.GetOutputDirectory();

string runtimeConfigFile = Path.Combine(outputDirectory.FullName, testProject.Name + ".runtimeconfig.json");
var runtimeFrameworkNames = GetRuntimeFrameworks(runtimeConfigFile);
Expand All @@ -712,7 +712,7 @@ public void TransitiveFrameworkReferenceFromProjectReference()
runtimeFrameworkNames.Should().BeEquivalentTo("Microsoft.AspNetCore.App", "Microsoft.NETCore.App");
}

[Fact]
[Fact(Skip = "https://github.com/NuGet/Home/issues/12323")]
public void TransitiveFrameworkReferenceFromPackageReference()
{
var referencedPackage = new TestProject()
Expand Down Expand Up @@ -755,7 +755,7 @@ public void TransitiveFrameworkReferenceFromPackageReference()
.Should()
.Pass();

var outputDirectory = buildCommand.GetOutputDirectory(testProject.TargetFrameworks);
var outputDirectory = buildCommand.GetOutputDirectory();

string runtimeConfigFile = Path.Combine(outputDirectory.FullName, testProject.Name + ".runtimeconfig.json");
var runtimeFrameworkNames = GetRuntimeFrameworks(runtimeConfigFile);
Expand Down Expand Up @@ -1005,7 +1005,7 @@ private void TestFrameworkReferenceProfiles(

if (selfContained)
{
var outputDirectory = buildCommand.GetOutputDirectory(testProject.TargetFrameworks, runtimeIdentifier: testProject.RuntimeIdentifier);
var outputDirectory = buildCommand.GetOutputDirectory(runtimeIdentifier: testProject.RuntimeIdentifier);

// The output directory should have the DLLs which are not referenced at compile time but are
// still part of the shared framework.
Expand Down Expand Up @@ -1110,13 +1110,13 @@ private ResolvedVersionInfo GetResolvedVersions(TestProject testProject,
testAsset = testAsset.WithProjectChanges(projectChanges);
}

var command = new MSBuildCommand(Log, "WriteResolvedVersions", Path.Combine(testAsset.TestRoot, testProject.Name));
var command = new MSBuildCommand(testAsset, "WriteResolvedVersions");

command.ExecuteWithoutRestore()
.Should()
.Pass();

var outputDirectory = command.GetOutputDirectory(testProject.TargetFrameworks, runtimeIdentifier: testProject.RuntimeIdentifier);
var outputDirectory = command.GetOutputDirectory(runtimeIdentifier: testProject.RuntimeIdentifier);
var resolvedVersions = ResolvedVersionInfo.ParseFrom(Path.Combine(outputDirectory.FullName, "resolvedversions.txt"));

return resolvedVersions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using System.Runtime.CompilerServices;
using Xunit;
using Xunit.Abstractions;
using static System.Net.WebRequestMethods;

namespace Microsoft.NET.Build.Tests
{
Expand All @@ -22,7 +23,7 @@ public class GivenThatWeHaveAPackageReferenceWithAliases : SdkTest
public GivenThatWeHaveAPackageReferenceWithAliases(ITestOutputHelper log) : base(log)
{ }

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

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

[RequiresMSBuildVersionFact("16.8.0")]
[RequiresMSBuildVersionFact("16.8.0", Skip = "https://github.com/NuGet/Home/issues/12323")]
public void CanBuildProjectWithAPackageReferenceWithMultipleAliases()
{
var targetFramework = ToolsetInfo.CurrentTargetFramework;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ internal static void TestSatelliteResources(
testAsset = testAsset.WithProjectChanges(projectChanges);
}

if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
// Also target desktop on Windows to get more test coverage:
// * Desktop requires satellites to have same public key as parent whereas coreclr does not.
// * Reference path handling of satellite assembly generation used to be incorrect for desktop.
testAsset = testAsset.WithTargetFrameworks($"{ToolsetInfo.CurrentTargetFramework};net46");
}

var buildCommand = new BuildCommand(testAsset);

if (setup != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ public void It_has_target_path_and_final_outputput_path_metadata(string targetFr
.WithTargetFramework(targetFramework);

var command = new GetValuesCommand(
Log,
testAsset.TestRoot,
targetFramework,
testAsset,
"BuiltProjectOutputGroupOutput",
GetValuesCommand.ValueType.Item)
{
Expand All @@ -44,7 +42,8 @@ public void It_has_target_path_and_final_outputput_path_metadata(string targetFr

command.Execute().Should().Pass();

var outputDirectory = command.GetOutputDirectory(targetFramework);
var outputDirectory = command.GetOutputDirectory();

var runtimeConfigFile = outputDirectory.File("HelloWorld.runtimeconfig.json");
var (_, metadata) = command.GetValuesWithMetadata().Single(i => i.value == runtimeConfigFile.FullName);

Expand All @@ -65,12 +64,14 @@ public void It_has_runtime_config_properties_after_partial_build()
};
var testAsset = _testAssetsManager.CreateTestProject(testProject, testProject.Name);

new BuildCommand(testAsset)
var buildCommand = new BuildCommand(testAsset);

buildCommand
.Execute("/property:Configuration=Release")
.Should()
.Pass();

var configFile = Path.Combine(testAsset.TestRoot, testProject.Name, "bin", "Release", testProject.TargetFrameworks, testProject.RuntimeIdentifier, testProject.Name + ".runtimeconfig.json");
var configFile = Path.Combine(buildCommand.GetOutputDirectory(configuration: "Release").FullName, testProject.Name + ".runtimeconfig.json");

File.Exists(configFile).Should().BeTrue();
File.ReadAllText(configFile).Should().NotContain("\"System.Runtime.TieredCompilation\"");
Expand Down Expand Up @@ -120,12 +121,14 @@ public void It_updates_runtime_config_properties_after_partial_build()
propertyGroup.Add(new XElement(ns + "ThreadPoolMinThreads", "3"));
});

new BuildCommand(testAsset)
var buildCommand = new BuildCommand(testAsset);

buildCommand
.Execute("/property:Configuration=Release")
.Should()
.Pass();

var configFile = Path.Combine(testAsset.TestRoot, testProject.Name, "bin", "Release", testProject.TargetFrameworks, testProject.RuntimeIdentifier, testProject.Name + ".runtimeconfig.json");
var configFile = Path.Combine(buildCommand.GetOutputDirectory(configuration: "Release").FullName, testProject.Name + ".runtimeconfig.json");

File.Exists(configFile).Should().BeTrue();
File.ReadAllText(configFile).Should().Contain("\"System.Runtime.TieredCompilation\": true");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using FluentAssertions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

namespace Microsoft.NET.Build.Tests
{
Expand All @@ -28,6 +29,14 @@ private void RestoreAndBuildTestAssets([CallerMemberName] string callingMethod =
.CopyTestAsset("AllResourcesInSatelliteDisableVersionGenerate", callingMethod)
.WithSource();

if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
// Also target desktop on Windows to get more test coverage:
// * Desktop requires satellites to have same public key as parent whereas coreclr does not.
// * Reference path handling of satellite assembly generation used to be incorrect for desktop.
testAsset = testAsset.WithTargetFrameworks($"{ToolsetInfo.CurrentTargetFramework};net46");
}

var buildCommand = new BuildCommand(testAsset);
buildCommand
.Execute()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void It_copies_the_comhost_to_the_output_directory()
.Should()
.Pass();

var outputDirectory = buildCommand.GetOutputDirectory(ToolsetInfo.CurrentTargetFramework);
var outputDirectory = buildCommand.GetOutputDirectory();

outputDirectory.Should().OnlyHaveFiles(new[] {
"ComServer.dll",
Expand Down Expand Up @@ -69,7 +69,7 @@ public void It_generates_a_regfree_com_manifest_when_requested()
.Should()
.Pass();

var outputDirectory = buildCommand.GetOutputDirectory(ToolsetInfo.CurrentTargetFramework);
var outputDirectory = buildCommand.GetOutputDirectory();

outputDirectory.Should().OnlyHaveFiles(new[] {
"ComServer.dll",
Expand Down Expand Up @@ -102,7 +102,7 @@ public void It_embeds_the_clsidmap_in_the_comhost_when_rid_specified(string rid)
.Should()
.Pass();

var outputDirectory = buildCommand.GetOutputDirectory(ToolsetInfo.CurrentTargetFramework, runtimeIdentifier: rid);
var outputDirectory = buildCommand.GetOutputDirectory(runtimeIdentifier: rid);

outputDirectory.Should().OnlyHaveFiles(new[] {
"ComServer.dll",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ public GivenThatWeWantToBuildACrossTargetedLibrary(ITestOutputHelper log) : base
public void It_builds_nondesktop_library_successfully_on_all_platforms()
{
var testAsset = _testAssetsManager
.CopyTestAsset("CrossTargeting")
.CopyTestAsset(Path.Combine("CrossTargeting", "NetStandardAndNetCoreApp"))
.WithSource();

var buildCommand = new BuildCommand(testAsset, "NetStandardAndNetCoreApp");
var buildCommand = new BuildCommand(testAsset);
buildCommand
.Execute()
.Should()
.Pass();

var outputDirectory = buildCommand.GetOutputDirectory(targetFramework: "");
var outputDirectory = new DirectoryInfo(Path.Combine(buildCommand.ProjectRootPath, "bin", "Debug"));
outputDirectory.Should().OnlyHaveFiles(new[] {
$"{ToolsetInfo.CurrentTargetFramework}/NetStandardAndNetCoreApp.dll",
$"{ToolsetInfo.CurrentTargetFramework}/NetStandardAndNetCoreApp.pdb",
Expand Down Expand Up @@ -61,7 +61,7 @@ public void It_builds_desktop_library_successfully_on_windows()
.Should()
.Pass();

var outputDirectory = buildCommand.GetOutputDirectory(targetFramework: "");
var outputDirectory = new DirectoryInfo(Path.Combine(buildCommand.ProjectRootPath, "bin", "Debug"));
outputDirectory.Should().OnlyHaveFiles(new[] {
"net40/DesktopAndNetStandard.dll",
"net40/DesktopAndNetStandard.pdb",
Expand Down
Loading