Skip to content

Commit 6160b78

Browse files
committed
Fix issue where ASP.NET tests or tools could run on Stage 0 Microsoft.NETCore.App shared framework
1 parent 544faef commit 6160b78

File tree

3 files changed

+34
-6
lines changed

3 files changed

+34
-6
lines changed

Directory.Build.targets

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,8 @@
4545
RuntimeFrameworkVersion="$(MicrosoftNETCoreAppRuntimePackageVersion)" />
4646
</ItemGroup>
4747

48+
<Import Project="src\Layout\redist\targets\BuildToolsetTasks.targets" Condition="'$(MSBuildProjectName)' != 'toolset-tasks'"/>
49+
50+
51+
4852
</Project>

src/Layout/redist/redist.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
<EnableNETAnalyzers>false</EnableNETAnalyzers>
1212
</PropertyGroup>
1313

14-
<Import Project="targets\BuildToolsetTasks.targets" />
14+
<!-- This is currently imported in Directory.Build.targets -->
15+
<!--<Import Project="targets\BuildToolsetTasks.targets" />-->
16+
1517
<Import Project="targets\GetRuntimeInformation.targets" />
1618
<Import Project="targets\Version.targets" />
1719
<Import Project="targets\BundledSdks.targets" />

src/Layout/redist/targets/BuildToolsetTasks.targets

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,28 @@
44
<TaskTargetFramework>$(SdkTargetFramework)</TaskTargetFramework>
55
<TaskTargetFramework Condition="'$(MSBuildRuntimeType)' != 'Core'">net472</TaskTargetFramework>
66

7-
<ToolsetTaskDll>$(ArtifactsDir)tasks\bin\toolset-tasks\$(Configuration)\$(TaskTargetFramework)\toolset-tasks.dll</ToolsetTaskDll>
7+
<!--<ToolsetTaskDll>$(ArtifactsDir)tasks\bin\toolset-tasks\$(Configuration)\$(TaskTargetFramework)\toolset-tasks.dll</ToolsetTaskDll>-->
8+
<ToolsetTaskDll>$(ArtifactsDir)bin\toolset-tasks\$(Configuration)\$(TaskTargetFramework)\toolset-tasks.dll</ToolsetTaskDll>
89
<ToolsetTaskProject>$(RepoRoot)src\Layout\toolset-tasks\toolset-tasks.csproj</ToolsetTaskProject>
910
</PropertyGroup>
10-
<Target Name="BuildCoreSdkTasks" BeforeTargets="_CheckForInvalidConfigurationAndPlatform">
11-
<!-- Use a different ArtifactsDir for this invocation so that the tasks project can be part of the solution
12-
(for easy editing), but we don't hit problems with the tasks DLL being locked when we try to build the solution. -->
11+
12+
<!-- Right now we're using these tasks in all projects, so we build with a ProjectReference. Once https://github.com/dotnet/sdk/pull/17982
13+
is merged and flows through to stage 0, we can delete the PatchRuntimeConfig target and go back to the way it was. -->
14+
<ItemGroup>
15+
<ProjectReference Include="$(ToolsetTaskProject)" ReferenceOutputAssembly="false" SkipGetTargetFrameworkProperties="true" SetTargetFramework="TargetFramework=$(TaskTargetFramework)" />
16+
</ItemGroup>
17+
18+
<!--<Target Name="BuildCoreSdkTasks" BeforeTargets="_CheckForInvalidConfigurationAndPlatform">
19+
--><!-- Use a different ArtifactsDir for this invocation so that the tasks project can be part of the solution
20+
(for easy editing), but we don't hit problems with the tasks DLL being locked when we try to build the solution. --><!--
1321
1422
<MSBuild Projects="$(ToolsetTaskProject)"
1523
Properties="ArtifactsDir=$(ArtifactsDir)tasks\;Phase=Restore"
1624
Targets="Restore"/>
1725
1826
<MSBuild Projects="$(ToolsetTaskProject)"
1927
Properties="ArtifactsDir=$(ArtifactsDir)tasks\"/>
20-
</Target>
28+
</Target>-->
2129

2230
<UsingTask TaskName="ReplaceFileContents" AssemblyFile="$(ToolsetTaskDll)" />
2331
<UsingTask TaskName="Chmod" AssemblyFile="$(ToolsetTaskDll)" />
@@ -27,4 +35,18 @@
2735
<UsingTask TaskName="ZipFileCreateFromDirectory" AssemblyFile="$(ToolsetTaskDll)"/>
2836
<UsingTask TaskName="OverrideAndCreateBundledNETCoreAppPackageVersion" AssemblyFile="$(ToolsetTaskDll)"/>
2937

38+
<Target Name="PatchRuntimeConfig" AfterTargets="GenerateBuildRuntimeConfigurationFiles"
39+
Condition="'$(MSBuildProjectName)' != 'toolset-tasks' And '$(MSBuildProjectName)' != 'HelixTasks' And Exists($(ProjectRuntimeConfigFilePath))">
40+
41+
<!-- Currently, GenerateRuntimeConfigurationFiles omits the reference to Microsoft.NETCore.App from the runtimeconfig file when there is a different
42+
shared framework. In this repo, this can cause the tests or tools such as dotnet-watch to use the stage 0 version of Microsoft.NETCore.App
43+
instead of the version specified in Versions.props. This can cause failures when there are changes to the base framework, as we compile against
44+
the one specified in Versions.props, but the project runs against an earlier version.
45+
46+
This task works around this by adding Microsoft.NETCore.App back to the list of runtimes in the runtimeconfig file if it's not there already. -->
47+
48+
<AddBaseFrameworkToRuntimeConfig RuntimeConfigPath="$(ProjectRuntimeConfigFilePath)" MicrosoftNetCoreAppVersion="$(VSRedistCommonNetCoreSharedFrameworkx6460PackageVersion)" />
49+
50+
</Target>
51+
3052
</Project>

0 commit comments

Comments
 (0)