Reputation: 21
I have an asp web server target framework is .NET Framework 4.6.1,
<TargetFramework>net461</TargetFramework>
I would like to add this project to a Windows application package and generate an installer. After I build the package, an error message:
target'net461' it cannot be referenced by a project that targets '.NETCore,Version=v5.0'.
Severity Code Description Project File Line Suppression State Error Project '..\Example\Example.csproj' targets 'net461'. It cannot be referenced by a project that targets '.NETCore,Version=v5.0'. ExamplePackage C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets 1653
I think it because windows application packaging has a default target framework but I have no idea how to change it. Could someone help me with this ?
Upvotes: 1
Views: 928
Reputation: 317
I've found a solution:
You should specify on the project xml, under each reference, which target framework to use, like this:
<SetTargetFramework>TargetFramework=net461</SetTargetFramework>
Complete example for a given reference
<ProjectReference Include="theProject.csproj">
<Name>theProject</Name>
<Project>{46e70050-559c-442f-b47d-99a3ad73afd3}</Project>
<Private>True</Private>
<DoNotHarvest>True</DoNotHarvest>
<RefProjectOutputGroups>Binaries;Content;Satellites</RefProjectOutputGroups>
<RefTargetDir>INSTALLFOLDER</RefTargetDir>
<SetTargetFramework>TargetFramework=net461</SetTargetFramework>
</ProjectReference>
Upvotes: 1