Skip to content

Revert workaround for runtimeconfig generation issue #18372

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

Merged
merged 3 commits into from
Jul 8, 2021
Merged
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
4 changes: 0 additions & 4 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,4 @@
RuntimeFrameworkVersion="$(MicrosoftNETCoreAppRuntimePackageVersion)" />
</ItemGroup>

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



</Project>
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"tools": {
"dotnet": "6.0.100-preview.6.21301.1",
"dotnet": "6.0.100-preview.7.21356.4",
"runtimes": {
"dotnet": [
"$(VSRedistCommonNetCoreSharedFrameworkx6460PackageVersion)"
Expand Down
4 changes: 1 addition & 3 deletions src/Layout/redist/redist.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
<EnableNETAnalyzers>false</EnableNETAnalyzers>
</PropertyGroup>

<!-- This is currently imported in Directory.Build.targets -->
<!--<Import Project="targets\BuildToolsetTasks.targets" />-->

<Import Project="targets\BuildToolsetTasks.targets" />
<Import Project="targets\GetRuntimeInformation.targets" />
<Import Project="targets\Version.targets" />
<Import Project="targets\BundledSdks.targets" />
Expand Down
33 changes: 5 additions & 28 deletions src/Layout/redist/targets/BuildToolsetTasks.targets
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,20 @@
<TaskTargetFramework>$(SdkTargetFramework)</TaskTargetFramework>
<TaskTargetFramework Condition="'$(MSBuildRuntimeType)' != 'Core'">net472</TaskTargetFramework>

<!--<ToolsetTaskDll>$(ArtifactsDir)tasks\bin\toolset-tasks\$(Configuration)\$(TaskTargetFramework)\toolset-tasks.dll</ToolsetTaskDll>-->
<ToolsetTaskDll>$(ArtifactsDir)bin\toolset-tasks\$(Configuration)\$(TaskTargetFramework)\toolset-tasks.dll</ToolsetTaskDll>
<ToolsetTaskDll>$(ArtifactsDir)tasks\bin\toolset-tasks\$(Configuration)\$(TaskTargetFramework)\toolset-tasks.dll</ToolsetTaskDll>
<ToolsetTaskProject>$(RepoRoot)src\Layout\toolset-tasks\toolset-tasks.csproj</ToolsetTaskProject>
</PropertyGroup>

<!-- Right now we're using these tasks in all projects, so we build with a ProjectReference. Once https://github.com/dotnet/sdk/pull/17982
is merged and flows through to stage 0, we can delete the PatchRuntimeConfig target and go back to the way it was. -->
<ItemGroup>
<ProjectReference Include="$(ToolsetTaskProject)" ReferenceOutputAssembly="false" SkipGetTargetFrameworkProperties="true" SetTargetFramework="TargetFramework=$(TaskTargetFramework)" />
</ItemGroup>

<!--<Target Name="BuildCoreSdkTasks" BeforeTargets="_CheckForInvalidConfigurationAndPlatform">
--><!-- Use a different ArtifactsDir for this invocation so that the tasks project can be part of the solution
(for easy editing), but we don't hit problems with the tasks DLL being locked when we try to build the solution. --><!--
<Target Name="BuildCoreSdkTasks" BeforeTargets="_CheckForInvalidConfigurationAndPlatform">
<!-- Use a different ArtifactsDir for this invocation so that the tasks project can be part of the solution
(for easy editing), but we don't hit problems with the tasks DLL being locked when we try to build the solution. -->

<MSBuild Projects="$(ToolsetTaskProject)"
Properties="ArtifactsDir=$(ArtifactsDir)tasks\;Phase=Restore"
Targets="Restore"/>

<MSBuild Projects="$(ToolsetTaskProject)"
Properties="ArtifactsDir=$(ArtifactsDir)tasks\"/>
</Target>-->
</Target>

<UsingTask TaskName="ReplaceFileContents" AssemblyFile="$(ToolsetTaskDll)" />
<UsingTask TaskName="Chmod" AssemblyFile="$(ToolsetTaskDll)" />
Expand All @@ -34,20 +26,5 @@
<UsingTask TaskName="GetCurrentRuntimeInformation" AssemblyFile="$(ToolsetTaskDll)"/>
<UsingTask TaskName="ZipFileCreateFromDirectory" AssemblyFile="$(ToolsetTaskDll)"/>
<UsingTask TaskName="OverrideAndCreateBundledNETCoreAppPackageVersion" AssemblyFile="$(ToolsetTaskDll)"/>
<UsingTask TaskName="AddBaseFrameworkToRuntimeConfig" AssemblyFile="$(ToolsetTaskDll)"/>

<Target Name="PatchRuntimeConfig" AfterTargets="GenerateBuildRuntimeConfigurationFiles"
Condition="'$(MSBuildProjectName)' != 'toolset-tasks' And '$(MSBuildProjectName)' != 'HelixTasks' And Exists($(ProjectRuntimeConfigFilePath))">

<!-- Currently, GenerateRuntimeConfigurationFiles omits the reference to Microsoft.NETCore.App from the runtimeconfig file when there is a different
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
instead of the version specified in Versions.props. This can cause failures when there are changes to the base framework, as we compile against
the one specified in Versions.props, but the project runs against an earlier version.

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. -->

<AddBaseFrameworkToRuntimeConfig RuntimeConfigPath="$(ProjectRuntimeConfigFilePath)" MicrosoftNetCoreAppVersion="$(VSRedistCommonNetCoreSharedFrameworkx6460PackageVersion)" />

</Target>

</Project>
64 changes: 0 additions & 64 deletions src/Layout/toolset-tasks/AddBaseFrameworkToRuntimeConfig.cs

This file was deleted.

7 changes: 0 additions & 7 deletions src/Layout/toolset-tasks/toolset-tasks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<TargetFrameworks>$(SdkTargetFramework);net472</TargetFrameworks>
<TargetFrameworks Condition=" '$([MSBuild]::IsOSPlatform(`Windows`))' == 'false' ">$(SdkTargetFramework)</TargetFrameworks>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<RootNamespace>Microsoft.DotNet.Build.Tasks</RootNamespace>
</PropertyGroup>

<ItemGroup>
Expand All @@ -14,12 +13,6 @@
<PackageReference Include="System.Reflection.Metadata" Version="1.4.2" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\..\Tasks\Microsoft.NET.Build.Tasks\RuntimeConfig.cs" LinkBase="RuntimeConfig"/>
<Compile Include="..\..\Tasks\Microsoft.NET.Build.Tasks\RuntimeOptions.cs" LinkBase="RuntimeConfig"/>
<Compile Include="..\..\Tasks\Microsoft.NET.Build.Tasks\RuntimeConfigFramework.cs" LinkBase="RuntimeConfig"/>
</ItemGroup>

<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
<Reference Include="System.Net.Http" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ public void It_builds_successfully_when_targeting_net_framework()
var project = XDocument.Load(projFile);
var ns = project.Root.Name.Namespace;
project.Root.Elements(ns + "PropertyGroup").Elements(ns + "TargetFramework").Single().Value = "net472";
// The template sets Nullable to "enable", which isn't supported on .NET Framework
project.Root.Elements(ns + "PropertyGroup").Elements(ns + "Nullable").Remove();
project.Save(projFile);

var buildCommand = new BuildCommand(Log, testDirectory);
Expand Down