UseWpf should work with netframework as a TargetFramework
See original GitHub issueAfter some headache trying to achieve a multitarget project with net47 and net5.0-windows. I would like to suggest that UseWpf should also work for net47.
My current project sadly has to look like this to make it “work”.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net47;net5.0-windows</TargetFrameworks>
<OutputType>WinExe</OutputType>
<RootNamespace>MyNamespace</RootNamespace>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net47' ">
<StartupObject>MyNamespace.App</StartupObject>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net5.0-windows' ">
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net47' ">
<!--
<EmbeddedResource Update="Properties\Resources.resx" Generator="ResXFileCodeGenerator" LastGenOutput="Resources.Designer.cs" />
<Compile Update="Properties\Resources.Designer.cs" DesignTime="True" AutoGen="True" DependentUpon="Resources.resx" />
<None Update="Properties\Settings.settings" Generator="SettingsSingleFileGenerator" LastGenOutput="Settings.Designer.cs" />
<Compile Update="Properties\Settings.Designer.cs" DesignTime="True" AutoGen="True" DependentUpon="Settings.settings">
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
-->
<Page Include="**\*.xaml" SubType="Designer" Generator="MSBuild:Compile" Exclude="App.xaml" />
<Compile Update="**\*.xaml.cs" SubType="Code" DependentUpon="%(Filename)" />
<ApplicationDefinition Include="App.xaml" SubType="Designer" Generator="XamlIntelliSenseFileGenerator" />
<Compile Update="App.xaml.cs" SubType="Code" DependentUpon="App.xaml" />
<Reference Include="System.Printing" />
<Reference Include="System.Windows" />
<Reference Include="System.Windows.Forms" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="PresentationFramework.Aero" />
<Reference Include="PresentationFramework.Aero2" />
<Reference Include="PresentationFramework.Luna" />
<Reference Include="PresentationUI">
<HintPath>C:\Windows\Microsoft.Net\assembly\GAC_MSIL\PresentationUI\v4.0_4.0.0.0__31bf3856ad364e35\PresentationUI.dll</HintPath>
</Reference>
<Reference Include="ReachFramework" />
<Reference Include="System.Xaml" />
<Reference Include="WindowsBase" />
</ItemGroup>
</Project>
My project file is a strange combination of this stackoverflow question https://stackoverflow.com/questions/43693591/how-to-migrate-wpf-projects-to-the-new-vs2017-format
Other question, why is it necessary for me to provide the HintPath
only for the assembly PresentationUI
?
All the other assemblies can be found without an issue, but if I would drop the HintPath
I would get a
14>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2123,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly “PresentationUI”. Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
I am not sure if that is the correct place to post this issue. If possible and I am wrong here move the issue to the correct place.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5
Top GitHub Comments
Microsoft.NET.Sdk
works with only net5. When multitarget, we should useMicrosoft.NET.Sdk.WindowsDesktop
.No need to do this. There’s no warning with multitarget project when use
Microsoft.NET.Sdk.WindowsDesktop
.