зеркало из https://github.com/dotnet/sdk.git
Use PackageDownload in torn builds (#41951)
This commit is contained in:
Родитель
a1f16b873d
Коммит
25cdd7a5b2
|
@ -88,19 +88,6 @@
|
|||
</ItemGroup>
|
||||
</Target>
|
||||
|
||||
<!-- Similarly to FSharp above, Roslyn needs to publish its Framework.Toolset package alongside SDK
|
||||
so it can be picked up in BuildWithNetFrameworkHostedCompiler scenarios. -->
|
||||
<PropertyGroup>
|
||||
<PublishDependsOnTargets>$(PublishDependsOnTargets);_ResolvePublishRoslynNuGetPackages</PublishDependsOnTargets>
|
||||
</PropertyGroup>
|
||||
|
||||
<Target Name="_ResolvePublishRoslynNuGetPackages" Condition="'$(EnableDefaultArtifacts)' == 'true'">
|
||||
<ItemGroup>
|
||||
<RoslynPackagesToPush Include="$(NuGetPackageRoot)\Microsoft.Net.Compilers.Toolset.Framework\$(MicrosoftNetCompilersToolsetFrameworkPackageVersion)\*.nupkg" />
|
||||
<ItemsToPushToBlobFeed Include="@(RoslynPackagesToPush)" IsShipping="true" />
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
|
||||
<!-- We use a separate target to publish this to blob storage so that we can push this to a relative path inside the blob storage. -->
|
||||
<Target Name="PublishToolsetAssets" DependsOnTargets="ReadToolsetVersion" BeforeTargets="Publish" Condition="'$(EnableDefaultArtifacts)' == 'true'">
|
||||
<ItemGroup>
|
||||
|
|
7
sdk.sln
7
sdk.sln
|
@ -509,6 +509,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.WebTools.AspireSe
|
|||
EndProject
|
||||
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Microsoft.WebTools.AspireService", "src\BuiltInTools\AspireService\Microsoft.WebTools.AspireService.shproj", "{94C8526E-DCC2-442F-9868-3DD0BA2688BE}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Net.Sdk.Compilers.Toolset", "src\Microsoft.Net.Sdk.Compilers.Toolset\Microsoft.Net.Sdk.Compilers.Toolset.csproj", "{FA579C03-2EB4-4D47-88EE-BFF339E96FAF}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
@ -971,6 +973,10 @@ Global
|
|||
{19014C60-F87C-4CC7-AC0F-C41B6126EBCE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{19014C60-F87C-4CC7-AC0F-C41B6126EBCE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{19014C60-F87C-4CC7-AC0F-C41B6126EBCE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{FA579C03-2EB4-4D47-88EE-BFF339E96FAF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FA579C03-2EB4-4D47-88EE-BFF339E96FAF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FA579C03-2EB4-4D47-88EE-BFF339E96FAF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FA579C03-2EB4-4D47-88EE-BFF339E96FAF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -1150,6 +1156,7 @@ Global
|
|||
{149E3D40-8115-4965-9305-5A1ADBF04899} = {580D1AE7-AA8F-4912-8B76-105594E00B3B}
|
||||
{19014C60-F87C-4CC7-AC0F-C41B6126EBCE} = {71A9F549-0EB6-41F9-BC16-4A6C5007FC91}
|
||||
{94C8526E-DCC2-442F-9868-3DD0BA2688BE} = {71A9F549-0EB6-41F9-BC16-4A6C5007FC91}
|
||||
{FA579C03-2EB4-4D47-88EE-BFF339E96FAF} = {22AB674F-ED91-4FBC-BFEE-8A1E82F9F05E}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {FB8F26CE-4DE6-433F-B32A-79183020BBD6}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>$(SdkTargetFramework)</TargetFramework>
|
||||
<Description>Transport package for Microsoft.Net.Compilers.Toolset.Framework assemblies. For internal use only.</Description>
|
||||
<IsPackable>true</IsPackable>
|
||||
<IncludeBuildOutput>false</IncludeBuildOutput>
|
||||
<NoPackageAnalysis>true</NoPackageAnalysis>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Net.Compilers.Toolset.Framework" ExcludeAssets="All" GeneratePathProperty="true" Condition="'$(DotNetBuildSourceOnly)' != 'true'" />
|
||||
<Content Include="$(PkgMicrosoft_Net_Compilers_Toolset_Framework)\tasks\net472\**\*" PackagePath="%(RecursiveDir)" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -220,24 +220,32 @@ Copyright (c) .NET Foundation. All rights reserved.
|
|||
</RebuildDependsOn>
|
||||
</PropertyGroup>
|
||||
|
||||
<Target Name="_AddMicrosoftNetCompilerToolsetFrameworkPackage" Condition="'$(MSBuildRuntimeType)' == 'Full'" BeforeTargets="CollectPackageReferences">
|
||||
<PropertyGroup Condition="'$(MSBuildRuntimeType)' == 'Full'">
|
||||
<!-- Automatically opt users into using the toolset package if they are running an MSBuild other than what this SDK was built against.
|
||||
This is to reduce 'tearing'/dependency mismatch, but as always users can override this behavior by disabling the hosted compiler flag. -->
|
||||
<BuildWithNetFrameworkHostedCompiler Condition="'$(BuildWithNetFrameworkHostedCompiler)' == '' and '$(_IsDisjointMSBuildVersion)' == 'true'">true</BuildWithNetFrameworkHostedCompiler>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(BuildWithNetFrameworkHostedCompiler)' == 'true' and '$(OS)' == 'Windows_NT'">
|
||||
<RoslynTargetsPath>$(NuGetPackageRoot)\microsoft.net.sdk.compilers.toolset\$(NETCoreSdkVersion)</RoslynTargetsPath>
|
||||
<_NeedToDownloadMicrosoftNetSdkCompilersToolsetPackage>true</_NeedToDownloadMicrosoftNetSdkCompilersToolsetPackage>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- NOTE: Keep in sync with https://github.com/dotnet/msbuild/blob/main/src/Tasks/Microsoft.Common.tasks -->
|
||||
<UsingTask TaskName="Microsoft.CodeAnalysis.BuildTasks.CopyRefAssembly" AssemblyFile="$(RoslynTargetsPath)\Microsoft.Build.Tasks.CodeAnalysis.dll" />
|
||||
<UsingTask TaskName="Microsoft.CodeAnalysis.BuildTasks.Csc" AssemblyFile="$(RoslynTargetsPath)\Microsoft.Build.Tasks.CodeAnalysis.dll" />
|
||||
<UsingTask TaskName="Microsoft.CodeAnalysis.BuildTasks.Vbc" AssemblyFile="$(RoslynTargetsPath)\Microsoft.Build.Tasks.CodeAnalysis.dll" />
|
||||
|
||||
<ItemGroup Condition="'$(_NeedToDownloadMicrosoftNetSdkCompilersToolsetPackage)' == 'true'">
|
||||
<PackageDownload Include="Microsoft.Net.Sdk.Compilers.Toolset" Version="[$(NETCoreSdkVersion)]" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="_CheckMicrosoftNetSdkCompilersToolsetPackageReference" Condition="'$(MSBuildRuntimeType)' == 'Full'" BeforeTargets="CollectPackageReferences">
|
||||
<!-- Users should not be setting Microsoft.Net.Compilers.Toolset.Framework directly.
|
||||
If they do, and they also set BuildWithNetFrameworkHostedCompiler, we will have
|
||||
a duplicate PackageReference. This makes it more explicit that that is not supported. -->
|
||||
If they do, and BuildWithNetFrameworkHostedCompiler is also set, the former will override the latter.
|
||||
This makes it more explicit that that is not supported. -->
|
||||
<NETSdkWarning ResourceName="CannotDirectlyReferenceMicrosoftNetCompilersToolsetFramework"
|
||||
Condition="'@(PackageReference->AnyHaveMetadataValue('Identity', 'Microsoft.Net.Compilers.Toolset.Framework'))' == 'true'" />
|
||||
|
||||
<PropertyGroup>
|
||||
<!-- Automatically opt users into using the toolset package if they are running an MSBuild other than what this SDK was built against.
|
||||
This is to reduce 'tearing'/depdendency mismatch, but as always users can override this behavior by disabling the hosted compiler flag. -->
|
||||
<BuildWithNetFrameworkHostedCompiler Condition="'$(BuildWithNetFrameworkHostedCompiler)' == '' and '$(_IsDisjointMSBuildVersion)' == 'true'">true</BuildWithNetFrameworkHostedCompiler>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="'$(BuildWithNetFrameworkHostedCompiler)' == 'true' and '$(OS)' == 'Windows_NT' ">
|
||||
<PackageReference Include="Microsoft.Net.Compilers.Toolset.Framework" PrivateAssets="all" Version="$(_NetFrameworkHostedCompilersVersion)" IsImplicitlyDefined="true" />
|
||||
</ItemGroup>
|
||||
|
||||
</Target>
|
||||
|
||||
<!-- TODO: this target should not check GeneratePackageOnBuild.
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace Microsoft.NET.Restore.Tests
|
|||
}
|
||||
|
||||
[FullMSBuildOnlyFact]
|
||||
public void It_restores_Microsoft_Net_Compilers_Toolset_Framework_when_requested()
|
||||
public void It_downloads_Microsoft_Net_Compilers_Toolset_Framework_when_requested()
|
||||
{
|
||||
const string testProjectName = "NetCoreApp";
|
||||
var project = new TestProject
|
||||
|
@ -24,21 +24,28 @@ namespace Microsoft.NET.Restore.Tests
|
|||
var testAsset = _testAssetsManager
|
||||
.CreateTestProject(project);
|
||||
|
||||
string projectAssetsJsonPath = Path.Combine(
|
||||
testAsset.Path,
|
||||
project.Name,
|
||||
"obj",
|
||||
"project.assets.json");
|
||||
NuGetConfigWriter.Write(testAsset.Path, TestContext.Current.TestPackages);
|
||||
|
||||
var restoreCommand =
|
||||
testAsset.GetRestoreCommand(Log, relativePath: testProjectName);
|
||||
restoreCommand.Execute().Should().Pass();
|
||||
var customPackagesDir = Path.Combine(testAsset.Path, "nuget-packages");
|
||||
|
||||
Assert.Contains("Microsoft.Net.Compilers.Toolset.Framework", File.ReadAllText(projectAssetsJsonPath));
|
||||
testAsset.GetRestoreCommand(Log, relativePath: testProjectName)
|
||||
.WithEnvironmentVariable("NUGET_PACKAGES", customPackagesDir)
|
||||
.Execute().Should().Pass();
|
||||
|
||||
var toolsetPackageDir = Path.Combine(customPackagesDir, "microsoft.net.sdk.compilers.toolset");
|
||||
|
||||
Assert.True(Directory.Exists(toolsetPackageDir));
|
||||
|
||||
var toolsetPackageVersion = Directory.EnumerateDirectories(toolsetPackageDir).Should().ContainSingle().Subject;
|
||||
|
||||
new BuildCommand(testAsset)
|
||||
.WithEnvironmentVariable("NUGET_PACKAGES", customPackagesDir)
|
||||
.Execute().Should().Pass().And
|
||||
.HaveStdOutContaining(Path.Combine(toolsetPackageDir, toolsetPackageVersion, "csc.exe") + " /noconfig");
|
||||
}
|
||||
|
||||
[FullMSBuildOnlyFact]
|
||||
public void It_restores_Microsoft_Net_Compilers_Toolset_Framework_when_MSBuild_is_torn()
|
||||
public void It_downloads_Microsoft_Net_Compilers_Toolset_Framework_when_MSBuild_is_torn()
|
||||
{
|
||||
const string testProjectName = "NetCoreApp";
|
||||
var project = new TestProject
|
||||
|
@ -53,24 +60,24 @@ namespace Microsoft.NET.Restore.Tests
|
|||
var testAsset = _testAssetsManager
|
||||
.CreateTestProject(project);
|
||||
|
||||
string projectAssetsJsonPath = Path.Combine(
|
||||
testAsset.Path,
|
||||
project.Name,
|
||||
"obj",
|
||||
"project.assets.json");
|
||||
NuGetConfigWriter.Write(testAsset.Path, TestContext.Current.TestPackages);
|
||||
|
||||
var restoreCommand =
|
||||
testAsset.GetRestoreCommand(Log, relativePath: testProjectName);
|
||||
restoreCommand.Execute().Should().Pass();
|
||||
var customPackagesDir = Path.Combine(testAsset.Path, "nuget-packages");
|
||||
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
Assert.Contains("Microsoft.Net.Compilers.Toolset.Framework", File.ReadAllText(projectAssetsJsonPath));
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.DoesNotContain("Microsoft.Net.Compilers.Toolset.Framework", File.ReadAllText(projectAssetsJsonPath));
|
||||
}
|
||||
testAsset.GetRestoreCommand(Log, relativePath: testProjectName)
|
||||
.WithEnvironmentVariable("NUGET_PACKAGES", customPackagesDir)
|
||||
.Execute().Should().Pass();
|
||||
|
||||
var toolsetPackageDir = Path.Combine(customPackagesDir, "microsoft.net.sdk.compilers.toolset");
|
||||
|
||||
Assert.True(Directory.Exists(toolsetPackageDir));
|
||||
|
||||
var toolsetPackageVersion = Directory.EnumerateDirectories(toolsetPackageDir).Should().ContainSingle().Subject;
|
||||
|
||||
new BuildCommand(testAsset)
|
||||
.WithEnvironmentVariable("NUGET_PACKAGES", customPackagesDir)
|
||||
.Execute().Should().Pass().And
|
||||
.HaveStdOutContaining(Path.Combine(toolsetPackageDir, toolsetPackageVersion, "csc.exe") + " /noconfig");
|
||||
}
|
||||
|
||||
[FullMSBuildOnlyFact]
|
||||
|
|
|
@ -154,6 +154,11 @@
|
|||
<Version>1.0.0</Version>
|
||||
<Clean>True</Clean>
|
||||
</BaseTestPackageProject>
|
||||
<BaseTestPackageProject Include="src/Microsoft.Net.Sdk.Compilers.Toolset">
|
||||
<Name>Microsoft.Net.Sdk.Compilers.Toolset</Name>
|
||||
<ProjectName>Microsoft.Net.Sdk.Compilers.Toolset.csproj</ProjectName>
|
||||
<Version>$(Version)</Version>
|
||||
</BaseTestPackageProject>
|
||||
|
||||
<BaseTestPackageProject>
|
||||
<NuPkgName Condition=" '%(NuPkgName)' == '' ">%(Name)</NuPkgName>
|
||||
|
|
Загрузка…
Ссылка в новой задаче