Using Visual Studio 2017, I created an ASP.NET Core site using .NET Framework.
(I do not have a project.json
, I have a VS2017 project with .cproj
)
My target is x64 Windows 2008R2. The beginning of my .cproj
looks like follow:
<Project Sdk="Microsoft.NET.Sdk.Web" ToolsVersion="15.0">
<PropertyGroup>
<TargetFrameworks>net462</TargetFrameworks>
<RuntimeIdentifier>win7-x64</RuntimeIdentifier>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<PlatformTarget>x64</PlatformTarget>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>TRACE;DEBUG</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<PlatformTarget>x64</PlatformTarget>
<OutputPath>bin\Release</OutputPath>
<Optimize>True</Optimize>
</PropertyGroup>
...
However, and while I am targetting .NET 4.6.2 only, when I try to publish I am getting this error
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk\buildCrossTargeting\Microsoft.NET.Sdk.targets(31,5): Error : The 'Publish' target is not supported without specifying a target framework. The current project targets multiple frameworks, please specify the framework for the published application.
While looking for solutions online, I encountered people having the same problem but they actually have many targets, however, in my case I am not sure why I am even getting it.
Any ideas?
To set target . NET runtime version to 6.0, enter <TargetFramework>net6. 0</TargetFramework> version in project's . csproj file directly.
The reason of targetFramework existence in web. config is to keep compatibility issues out between breaking changes for each version of . NET Framework. The difference between targetFramework on compilation and httpRuntime belongs to each development and deployment environment.
There was a change in the .csproj
template (https://github.com/dotnet/sdk/issues/251).
Instead of <TargetFrameworks>
you need to use <TargetFramework>
:
<PropertyGroup>
<TargetFramework>net462</TargetFramework>
<RuntimeIdentifier>win7-x64</RuntimeIdentifier>
</PropertyGroup>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With