Skip to content
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

WPF VCXProj projects should build against the runtime version it references #9490

Open
ericstj opened this issue Jul 30, 2024 · 1 comment · May be fixed by #10028
Open

WPF VCXProj projects should build against the runtime version it references #9490

ericstj opened this issue Jul 30, 2024 · 1 comment · May be fixed by #10028

Comments

@ericstj
Copy link
Member

ericstj commented Jul 30, 2024

WPF's VCXProj projects build against the targeting pack from the SDK. This creates problems like #9309 where WPF ends up building against older references than it ships with. It also causes problems where SDK's VMR build fails because it forces WPF to build with the latest runtime which might introduce a compiler warning due to new API - #9135.

Instead WPF should build against the version of runtime that it depends on.

I see VCXProj's are excluded -

<FrameworkReference Update="Microsoft.NETCore.App"
Condition="'$(MicrosoftNETCoreAppRefVersion)'!=''
And '$(NoTargets)'!='true'
And '$(TargetFrameworkIdentifier)' == '.NETCoreApp'
And $([MSBuild]::VersionGreaterThanOrEquals('$(TargetFrameworkVersion)', '3.0'))
And '$(MSBuildProjectExtension)'!='.vcxproj'">
<TargetingPackVersion>$(MicrosoftNETCoreAppRefVersion)</TargetingPackVersion>
</FrameworkReference>
<!--
Workaround - this should be removed when our tests are converted from Microsoft.NET.Sdk.WindowsDesktop => Microsoft.NET.Sdk
project
-->
<KnownFrameworkReference Remove="Microsoft.AspNetCore.App" />
</ItemGroup>
<PropertyGroup>
<RuntimeFrameworkVersion Condition="'$(MicrosoftNETCoreAppRuntimewinx64Version)'!='' And
'$(NoTargets)'!='true' And
'$(TargetFrameworkIdentifier)' == '.NETCoreApp' And
$([MSBuild]::VersionGreaterThanOrEquals('$(TargetFrameworkVersion)', '3.0')) And
'$(MSBuildProjectExtension)'!='.vcxproj'">$(MicrosoftNETCoreAppRuntimewinx64Version)</RuntimeFrameworkVersion>

If I try to remove that exclusion I see:

C:\src\dotnet\wpf\.dotnet\sdk\9.0.100-preview.5.24307.3\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(157,5): error NETSDK1145: The Apphost pack is not installed and NuGet package restore is not supported. Upgrade Visual Studio, remove global.json if
it specifies a certain SDK version, and uninstall the newer SDK. For more options visit   https://aka.ms/targeting-apphost-pack-missing  Pack Type:Apphost, Pack directory: C:\src\dotnet\wpf\.dotnet\packs\Microsoft.NETCore.App.Host.win-x86, targetframework: net9.0, Pack PackageId: Microsoft.
NETCore.App.Host.win-x86, Pack Package Version: 9.0.0-rc.1.24379.3 [C:\src\dotnet\wpf\src\Microsoft.DotNet.Wpf\src\DirectWriteForwarder\DirectWriteForwarder.vcxproj]

We ought to be able to workaround this somehow. Even if the VCXProj can't do the restore, other projects in the repo will do it, and the VCXproj should be able to get the path.

ericstj added a commit that referenced this issue Jul 30, 2024
WPF was depending on the package version of
System.Runtime.Serialization.Formatters but never shipping it.
�Instead WPF should depend on the built-in assembly version.
To do that we need to update the SDK version since WPF's vcxprojs don't
enable the nuget package targeting pack #9490
@ericstj
Copy link
Member Author

ericstj commented Jul 30, 2024

pchaurasia14 pushed a commit that referenced this issue Jul 30, 2024
WPF was depending on the package version of
System.Runtime.Serialization.Formatters but never shipping it.
�Instead WPF should depend on the built-in assembly version.
To do that we need to update the SDK version since WPF's vcxprojs don't
enable the nuget package targeting pack #9490
pchaurasia14 added a commit to pchaurasia14/wpf that referenced this issue Aug 1, 2024
WPF was depending on the package version of
System.Runtime.Serialization.Formatters but never shipping it.
�Instead WPF should depend on the built-in assembly version.
To do that we need to update the SDK version since WPF's vcxprojs don't
enable the nuget package targeting pack dotnet#9490
ericstj added a commit that referenced this issue Aug 1, 2024
WPF was depending on the package version of
System.Runtime.Serialization.Formatters but never shipping it.
�Instead WPF should depend on the built-in assembly version.
To do that we need to update the SDK version since WPF's vcxprojs don't
enable the nuget package targeting pack #9490
ViktorHofer added a commit that referenced this issue Nov 4, 2024
Fixes #9490
Unblocks dotnet/sdk#43015

When building wpf inside the VMR, a 10.0.100 SDK is used. WPF currently still targets net9.0. As WPF directly depends on runtime, it already uses 10.0.0-alpha versions of the targeting and runtime packs for managed projects.

Enable this for vcxprojs as well so that the host packages can also be restored from the flowing runtime dependency.

Fixes errors like these:

> The Apphost pack is not installed and NuGet package restore is not supported. Upgrade Visual Studio, remove global.json if it specifies a certain SDK version, and uninstall the newer SDK. For more options visit   https://aka.ms/targeting-apphost-pack-missing  Pack Type:Apphost, Pack directory: D:\a\_work\1\vmr\.dotnet\packs\Microsoft.NETCore.App.Host.win-x64, targetframework: net9.0, Pack PackageId: Microsoft.NETCore.App.Host.win-x64, Pack Package Version: 9.0.0-rc.2.24473.5
@ViktorHofer ViktorHofer linked a pull request Nov 4, 2024 that will close this issue
ViktorHofer added a commit that referenced this issue Nov 4, 2024
Fixes #9490
Unblocks dotnet/sdk#43015

When building wpf inside the VMR, a 10.0.100 SDK is used. WPF currently still targets net9.0. As WPF directly depends on runtime, it already uses 10.0.0-alpha versions of the targeting and runtime packs for managed projects.

Enable this for vcxprojs as well so that the host packages can also be restored from the flowing runtime dependency.

Fixes errors like these:

> The Apphost pack is not installed and NuGet package restore is not supported. Upgrade Visual Studio, remove global.json if it specifies a certain SDK version, and uninstall the newer SDK. For more options visit   https://aka.ms/targeting-apphost-pack-missing  Pack Type:Apphost, Pack directory: D:\a\_work\1\vmr\.dotnet\packs\Microsoft.NETCore.App.Host.win-x64, targetframework: net9.0, Pack PackageId: Microsoft.NETCore.App.Host.win-x64, Pack Package Version: 9.0.0-rc.2.24473.5
ViktorHofer added a commit that referenced this issue Nov 6, 2024
Fixes #9490
Unblocks dotnet/sdk#43015

When building wpf inside the VMR, a 10.0.100 SDK is used. WPF currently still targets net9.0. As WPF directly depends on runtime, it already uses 10.0.0-alpha versions of the targeting and runtime packs for managed projects.

Enable this for vcxprojs as well so that the host packages can also be restored from the flowing runtime dependency.

Fixes errors like these:

> The Apphost pack is not installed and NuGet package restore is not supported. Upgrade Visual Studio, remove global.json if it specifies a certain SDK version, and uninstall the newer SDK. For more options visit   https://aka.ms/targeting-apphost-pack-missing  Pack Type:Apphost, Pack directory: D:\a\_work\1\vmr\.dotnet\packs\Microsoft.NETCore.App.Host.win-x64, targetframework: net9.0, Pack PackageId: Microsoft.NETCore.App.Host.win-x64, Pack Package Version: 9.0.0-rc.2.24473.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant