Skip to content

Don't put testing global.json in artifacts dir directly #49819

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<TestHostFolder>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'redist', '$(Configuration)'))</TestHostFolder>
<TestHostDotNetRoot>$([MSBuild]::NormalizeDirectory('$(TestHostFolder)', 'dotnet'))</TestHostDotNetRoot>
<TestHostDotNetTool>$(TestHostDotNetRoot)$([System.IO.Path]::GetFileName('$(DotNetTool)'))</TestHostDotNetTool>
<TestLayoutDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsTmpDir)', 'testing'))</TestLayoutDir>

<PackageProjectUrl>https://github.com/dotnet/sdk</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@

<!-- Copy to *.csproj for using in sanity checks integration tests. -->
<Target Name="CopyCsprojToTestExecutionDirectory" AfterTargets="Build">
<Copy SourceFiles="$(MSBuildThisFileFullPath)" DestinationFiles="$(ArtifactsTmpDir)Container\ProjectFiles\$(MSBuildThisFileName).csproj" SkipUnchangedFiles="true" />
<Copy SourceFiles="$(MSBuildThisFileFullPath)" DestinationFiles="$(TestLayoutDir)Container\ProjectFiles\$(MSBuildThisFileName).csproj" SkipUnchangedFiles="true" />
</Target>

</Project>
4 changes: 2 additions & 2 deletions src/Containers/containerize/containerize.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
<ItemGroup>
<ContainerizeFiles Include="$(ArtifactsBinDir)containerize\$(Configuration)\$(SdkTargetFramework)\**\*.*" />
</ItemGroup>
<Copy SourceFiles="@(ContainerizeFiles)" DestinationFiles="@(ContainerizeFiles->'$(ArtifactsTmpDir)Container\containerize\%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="true" />
<Copy SourceFiles="@(ContainerizeFiles)" DestinationFiles="@(ContainerizeFiles->'$(TestLayoutDir)Container\containerize\%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="true" />
</Target>

<!-- Copy to *.csproj for using in sanity checks integration tests. -->
<Target Name="CopyCsprojToTestExecutionDirectory" AfterTargets="Build">
<Copy SourceFiles="$(MSBuildThisFileFullPath)" DestinationFiles="$(ArtifactsTmpDir)Container\ProjectFiles\$(MSBuildThisFileName).csproj" SkipUnchangedFiles="true" />
<Copy SourceFiles="$(MSBuildThisFileFullPath)" DestinationFiles="$(TestLayoutDir)Container\ProjectFiles\$(MSBuildThisFileName).csproj" SkipUnchangedFiles="true" />
</Target>
</Project>
8 changes: 4 additions & 4 deletions src/Containers/packaging/package.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
$([MSBuild]::ValueOrDefault('%(_AllNet472ContainerTaskDependencies.NuGetPackageId)', '').Contains('Microsoft.Extensions'))
) and
%(_AllNet472ContainerTaskDependencies.NuGetIsFrameworkReference) != true" />

<!-- containerize folder -->
<Content Include="$(OutDir)containerize.dll" Pack="true" PackagePath="containerize/" />
<Content Include="$(OutDir)containerize.runtimeconfig.json" Pack="true" PackagePath="containerize/" />
Expand Down Expand Up @@ -104,14 +104,14 @@
<!-- Hacky workaround for the fact that we don't publish the package yet. -->
<Target Name="CopyNupkgToCustomFolder" AfterTargets="Pack">
<Copy SourceFiles="$(ArtifactsDir)packages/$(Configuration)/Shipping/Microsoft.NET.Build.Containers.$(Version).nupkg"
DestinationFiles="$(ArtifactsTmpDir)Container/package/Microsoft.NET.Build.Containers.$(Version).nupkg" />
DestinationFiles="$(TestLayoutDir)Container/package/Microsoft.NET.Build.Containers.$(Version).nupkg" />
</Target>

<!-- Copy files that are needed by Integration tests. -->
<Target Name="CopyPropsAndTargets" AfterTargets="Pack">
<Copy SourceFiles="./build/Microsoft.NET.Build.Containers.props"
DestinationFiles="$(ArtifactsTmpDir)Container/packaging/Microsoft.NET.Build.Containers.props" />
DestinationFiles="$(TestLayoutDir)Container/packaging/Microsoft.NET.Build.Containers.props" />
<Copy SourceFiles="./build/Microsoft.NET.Build.Containers.targets"
DestinationFiles="$(ArtifactsTmpDir)Container/packaging/Microsoft.NET.Build.Containers.targets" />
DestinationFiles="$(TestLayoutDir)Container/packaging/Microsoft.NET.Build.Containers.targets" />
</Target>
</Project>
14 changes: 7 additions & 7 deletions src/Layout/redist/targets/GenerateTestingGlobalJson.targets
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project>
<PropertyGroup>
<!-- We put this in the root of the artifacts dir so that any usage (not just from ./tmp, but also from ./bin) gets redirected. -->
<_TestingGlobalJsonPath>$(ArtifactsDir)global.json</_TestingGlobalJsonPath>
</PropertyGroup>
<ItemGroup>
<_TestingGlobalJsonPath Include="$(ArtifactsBinDir)global.json" />
<_TestingGlobalJsonPath Include="$(TestLayoutDir)global.json" />
</ItemGroup>

<!-- Since the dotnet binary respects sdk.paths in global.json now, and we use this in the repo root to make sure that we consistently use the repo-local
SDK for building/etc, we need to put something in place so that tests don't use the repo-local SDK and instead use the redist SDK. -->
<Target Name="CreateRedistGlobalJsonForTesting"
BeforeTargets="AfterBuild"
Outputs="$(_TestingGlobalJsonPath)">
Outputs="@(_TestingGlobalJsonPath)">
<PropertyGroup>
<_TestingRedistDotnetPath>$(TestHostDotNetRoot.Replace('\', '\\'))</_TestingRedistDotnetPath>
</PropertyGroup>
Expand All @@ -21,13 +21,13 @@
<_RedistGlobalJsonLines Include=" }" />
<_RedistGlobalJsonLines Include="}" />
</ItemGroup>
<WriteLinesToFile File="$(_TestingGlobalJsonPath)"
<WriteLinesToFile File="%(_TestingGlobalJsonPath.Identity)"
Lines="@(_RedistGlobalJsonLines)"
Overwrite="true"
Encoding="utf-8"
WriteOnlyWhenDifferent="true" />
<ItemGroup>
<FileWrites Include="$(_TestingGlobalJsonPath)" />
<FileWrites Include="@(_TestingGlobalJsonPath)" />
</ItemGroup>
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<IncludeBuildOutput>False</IncludeBuildOutput>
<IncludeSource>False</IncludeSource>
<GenerateAssemblyInfo>False</GenerateAssemblyInfo>
<OutputPath>$(ArtifactsTmpDir)</OutputPath>
<OutputPath>$(TestLayoutDir)</OutputPath>
<EnableDefaultItems>False</EnableDefaultItems>
<UsingToolTemplateLocalizer>true</UsingToolTemplateLocalizer>
<IsPackable>true</IsPackable>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<IncludeBuildOutput>False</IncludeBuildOutput>
<IncludeSource>False</IncludeSource>
<GenerateAssemblyInfo>False</GenerateAssemblyInfo>
<OutputPath>$(ArtifactsTmpDir)</OutputPath>
<OutputPath>$(TestLayoutDir)</OutputPath>
<EnableDefaultItems>False</EnableDefaultItems>
<UsingToolTemplateLocalizer>true</UsingToolTemplateLocalizer>
<IsPackable>true</IsPackable>
Expand Down
12 changes: 6 additions & 6 deletions test/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@
<!-- Set this to true for test project only because test assets contains .editorconfig file -->
<NoDefaultExcludes>true</NoDefaultExcludes>
</PropertyGroup>

<ItemGroup Condition="'$(IsTestProject)' == 'true' AND '$(OutputType)' == 'Exe' AND '$(TargetFrameworkIdentifier)' == '.NETCoreApp'">
<Compile Include="$(MSBuildThisFileDirectory)Common\Program.cs" />
</ItemGroup>

<Target Name="TestAsTool" DependsOnTargets="Pack;_InnerGetTestsToRun">
<PropertyGroup>
<TestLocalToolFolder>$(ArtifactsTmpDir)$(ToolCommandName)\</TestLocalToolFolder>
<TestLocalToolExecutionFolder>$(ArtifactsTmpDir)$(ToolCommandName)\w</TestLocalToolExecutionFolder>
<DOTNET_CLI_HOME>$(ArtifactsTmpDir)DOTNET_CLI_HOME\</DOTNET_CLI_HOME>
<TestLocalToolFolder>$(TestLayoutDir)$(ToolCommandName)\</TestLocalToolFolder>
<TestLocalToolExecutionFolder>$(TestLayoutDir)$(ToolCommandName)\w</TestLocalToolExecutionFolder>
<DOTNET_CLI_HOME>$(TestLayoutDir)DOTNET_CLI_HOME\</DOTNET_CLI_HOME>
</PropertyGroup>

<RemoveDir Directories="$(TestLocalToolExecutionFolder)" />
Expand All @@ -46,11 +46,11 @@
IgnoreStandardErrorWarningFormat="true"
WorkingDirectory="$(TestLocalToolFolder)"
EnvironmentVariables="DOTNET_CLI_HOME=$(DOTNET_CLI_HOME)"/>

<Exec Command="dotnet tool install --local $(ToolCommandName) --version $(PackageVersion) --add-source $(ArtifactsNonShippingPackagesDir)"
WorkingDirectory="$(TestLocalToolFolder)"
EnvironmentVariables="DOTNET_CLI_HOME=$(DOTNET_CLI_HOME)"/>

<Exec Command="dotnet tool restore"
WorkingDirectory="$(TestLocalToolFolder)"
EnvironmentVariables="DOTNET_CLI_HOME=$(DOTNET_CLI_HOME)"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class TestToolBuilderCollection : ICollectionFixture<TestToolBuilder>
// global packages folder to ensure that the newly built package is used the next time a test tries to install it.
//
// The main thing this class can't handle is if the way the .NET SDK builds packages changes. In CI runs, we should use a clean test execution folder each time (I think!), so this shouldn't be an issue.
// For local testing, you may need to delete the artifacts\tmp\Debug\TestTools folder if the SDK changes in a way that affects the built package.
// For local testing, you may need to delete the artifacts\tmp\Debug\testing\TestTools folder if the SDK changes in a way that affects the built package.
public class TestToolBuilder
{
public class TestToolSettings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ public void ResolvesContentType_ForCompressedAssets()
["AssetRole"] = "Alternative",
["AssetTraitValue"] = "gzip",
["AssetTraitName"] = "Content-Encoding",
["OriginalItemSpec"] = Path.Combine("D:", "work", "dotnet-sdk", "artifacts", "tmp", "Release", "Publish60Host---0200F604", "Client", "bin", "Debug", "net6.0", "wwwroot", "_framework", "dotnet.timezones.blat"),
["OriginalItemSpec"] = Path.Combine("D:", "work", "dotnet-sdk", "artifacts", "tmp", "Release", "testing", "Publish60Host---0200F604", "Client", "bin", "Debug", "net6.0", "wwwroot", "_framework", "dotnet.timezones.blat"),
["CopyToPublishDirectory"] = "Never",
["FileLength"] = "10",
["LastWriteTime"] = lastWrite.ToString("ddd, dd MMM yyyy HH:mm:ss 'GMT'", CultureInfo.InvariantCulture)
Expand Down
2 changes: 1 addition & 1 deletion test/Microsoft.NET.TestFramework/BuildTestPackages.targets
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project ToolsVersion="14.0" DefaultTargets="Test">

<PropertyGroup>
<TestPackagesDir>$(ArtifactsTmpDir)testpackages/</TestPackagesDir>
<TestPackagesDir>$(TestLayoutDir)testpackages/</TestPackagesDir>
</PropertyGroup>

<Target Name="PrepareTests"
Expand Down
14 changes: 7 additions & 7 deletions test/Microsoft.NET.TestFramework/SetupTestRoot.targets
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@
</ItemGroup>

<ItemGroup>
<_CopyDirectoryBuildTestDependenciesOutput Include="$(ArtifactsTmpDir)Directory.Build.props" />
<_CopyDirectoryBuildTestDependenciesOutput Include="$(ArtifactsTmpDir)Directory.Build.targets" />
<_CopyDirectoryBuildTestDependenciesOutput Include="$(ArtifactsTmpDir).editorconfig" />
<_CopyDirectoryBuildTestDependenciesOutput Include="$(TestLayoutDir)Directory.Build.props" />
<_CopyDirectoryBuildTestDependenciesOutput Include="$(TestLayoutDir)Directory.Build.targets" />
<_CopyDirectoryBuildTestDependenciesOutput Include="$(TestLayoutDir).editorconfig" />
</ItemGroup>

<!-- Since TestFramework is multi-targeted, only copy these files for one of the inner builds -->
<Target Name="_CopyDirectoryBuildTestDependencies" AfterTargets="Build" Inputs="@(_CopyDirectoryBuildTestDependenciesInput)" Outputs="@(_CopyDirectoryBuildTestDependenciesOutput)"
Condition="'$(TargetFramework)' == '$(SdkTargetFramework)'">
<Copy SourceFiles="@(_CopyDirectoryBuildTestDependenciesInput)" DestinationFiles="@(_CopyDirectoryBuildTestDependenciesOutput)" />
</Target>
<Target Name="WriteNugetConfigFile"

<Target Name="WriteNugetConfigFile"
AfterTargets="Build"
Inputs="$(RepoRoot)NuGet.config"
Outputs="$(ArtifactsTmpDir)NuGet.config"
Outputs="$(TestLayoutDir)NuGet.config"
Condition="'$(TargetFramework)' == '$(SdkTargetFramework)'"
>
<Copy SourceFiles="$(RepoRoot)NuGet.config" DestinationFiles="$(ArtifactsTmpDir)NuGet.config" />
<Copy SourceFiles="$(RepoRoot)NuGet.config" DestinationFiles="$(TestLayoutDir)NuGet.config" />
</Target>

</Project>
4 changes: 2 additions & 2 deletions test/Microsoft.NET.TestFramework/TestContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public static void Initialize(TestCommandLine commandLine)
string? FindFolder2 = FindFolderInTree(Path.Combine("test", "TestAssets"), AppContext.BaseDirectory);
if (FindFolder1 is not null)
{
testContext.TestExecutionDirectory = Path.Combine(FindFolder1, "tmp", repoConfiguration);
testContext.TestExecutionDirectory = Path.Combine(FindFolder1, "tmp", repoConfiguration, "testing");
}
if (FindFolder2 is not null)
{
Expand Down Expand Up @@ -237,7 +237,7 @@ public static void Initialize(TestCommandLine commandLine)
testContext.NuGetExePath = Path.Combine(artifactsDir, ".nuget", $"nuget{Constants.ExeSuffix}");
testContext.NuGetCachePath = Path.Combine(artifactsDir, ".nuget", "packages");

testContext.TestPackages = Path.Combine(artifactsDir, "tmp", repoConfiguration, "testpackages");
testContext.TestPackages = Path.Combine(artifactsDir, "tmp", repoConfiguration, "testing", "testpackages");
}
else if (runAsTool)
{
Expand Down
2 changes: 1 addition & 1 deletion test/Microsoft.NET.TestFramework/ToolsetInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ public static ToolsetInfo Create(string? repoRoot, string? repoArtifactsDir, str

if (repoRoot != null && repoArtifactsDir is not null)
{
ret.CliHomePath = Path.Combine(repoArtifactsDir, "tmp", configuration);
ret.CliHomePath = Path.Combine(repoArtifactsDir, "tmp", configuration, "testing");
}

return ret;
Expand Down
14 changes: 7 additions & 7 deletions test/UnitTests.proj
Original file line number Diff line number Diff line change
Expand Up @@ -82,21 +82,21 @@
<!-- Get full framework msbuild end -->

<!-- include .dotnet folder. So there is no extra first run experience run during the test -->
<DotnetCliHome Include="$(ArtifactsTmpDir).dotnet\**\*.*" />
<DotnetCliHome Include="$(TestLayoutDir).dotnet\**\*.*" />

<Testpackages Include="$(ArtifactsTmpDir)testpackages\**\*.*" />
<Testpackages Include="$(TestLayoutDir)testpackages\**\*.*" />

<!-- include Container artifacts for running test in Helix -->
<ContainerFiles Include="$(ArtifactsTmpDir)Container\**\*.*" />
<ContainerFiles Include="$(TestLayoutDir)Container\**\*.*" />

<LockFiles Include="..\src\Tasks\Microsoft.NET.Build.Tasks.UnitTests\LockFiles\**\*.*" />

<AssetFiles Include="TestAssets\**\*.*" />

<!-- Files in testExecutionDirectory to prevent environment interference -->
<TestExecutionDirectoryFiles Include="$(ArtifactsTmpDir)NuGet.config" />
<TestExecutionDirectoryFiles Include="$(ArtifactsTmpDir)Directory.Build.props" />
<TestExecutionDirectoryFiles Include="$(ArtifactsTmpDir)Directory.Build.targets" />
<TestExecutionDirectoryFiles Include="$(TestLayoutDir)NuGet.config" />
<TestExecutionDirectoryFiles Include="$(TestLayoutDir)Directory.Build.props" />
<TestExecutionDirectoryFiles Include="$(TestLayoutDir)Directory.Build.targets" />
<TestExecutionDirectoryFiles Include="$(RepoRoot)testAsset.props" />
<TestExecutionDirectoryFiles Include="$(RepoRoot)eng\Versions.props">
<DestinationFolder>eng/</DestinationFolder>
Expand All @@ -105,7 +105,7 @@
<DestinationFolder>eng/</DestinationFolder>
</TestExecutionDirectoryFiles>

<FilesInHelixRoot Include="$(RepoRoot)artifacts\tmp\$(Configuration)\NuGet.config" />
<FilesInHelixRoot Include="$(TestLayoutDir)\NuGet.config" />
<FilesInHelixRoot Condition="$([MSBuild]::IsOSPlatform(`Windows`))" Include="$(RepoRoot)build\RunTestsOnHelix.cmd" />
<FilesInHelixRoot Condition=" '$([MSBuild]::IsOSPlatform(`Windows`))' == 'false' " Include="$(RepoRoot)build\RunTestsOnHelix.sh" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion test/dotnet-new.IntegrationTests/BaseIntegrationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static string GetTestTemplateLocation(string templateName)

/// <summary>
/// Creates a temp test directory under test execution folder.
/// Format: artifacts\tmp\Debug\dotnet-new.IntegrationTests\<paramref name="testName"/>\<paramref name="folderName"/>\date-time-utc-now[optional counter].
/// Format: artifacts\tmp\Debug\testing\dotnet-new.IntegrationTests\<paramref name="testName"/>\<paramref name="folderName"/>\date-time-utc-now[optional counter].
/// </summary>
/// <remarks>
/// Use this method when temp folder should be under location that is aware of repo nuget.config.
Expand Down
2 changes: 1 addition & 1 deletion test/dotnet-new.IntegrationTests/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ internal static string GetTestExecutionTempFolder()

/// <summary>
/// Creates a temp folder in location dedicated for dotnet-new.IntegrationTests.
/// Format: artifacts\tmp\Debug\dotnet-new.IntegrationTests\<paramref name="caller"/>\<paramref name="customName"/>\date-time-utc-now[optional counter].
/// Format: artifacts\tmp\Debug\testing\dotnet-new.IntegrationTests\<paramref name="caller"/>\<paramref name="customName"/>\date-time-utc-now[optional counter].
/// </summary>
internal static string CreateTemporaryFolder([CallerMemberName] string caller = "Unnamed", string customName = "")
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ namespace Microsoft.DotNet.Cli.New.IntegrationTests
<WriteLinesToFile Lines="$(GeneratedText)" File="$(GeneratedFilePath)" WriteOnlyWhenDifferent="true" Overwrite="true" />
</Target>

<Target Name="CopyDBFilesToArtifactsTmpDir" AfterTargets="Build">
<Copy SourceFiles="TestDirectoryBuildFiles/Directory.Build.props" DestinationFolder="$(ArtifactsTmpDir)" />
<Copy SourceFiles="TestDirectoryBuildFiles/Directory.Build.targets" DestinationFolder="$(ArtifactsTmpDir)" />
<Target Name="CopyDBFilesToTestLayoutDir" AfterTargets="Build">
<Copy SourceFiles="TestDirectoryBuildFiles/Directory.Build.props" DestinationFolder="$(TestLayoutDir)" />
<Copy SourceFiles="TestDirectoryBuildFiles/Directory.Build.targets" DestinationFolder="$(TestLayoutDir)" />
</Target>

<ItemGroup>
Expand Down
Loading