如果不指定目标框架,则不支持 'Publish' 目标
The 'Publish' target is not supported without specifying a target framework
使用 Visual Studio 2017,我使用 .NET Framework 创建了一个 ASP.NET 核心站点。
(我没有 project.json
,我有一个带有 .cproj
的 VS2017 项目)
我的目标是 x64 Windows 2008R2。我的 .cproj
的开头如下所示:
<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>
...
但是,虽然我只针对 .NET 4.6.2,但当我尝试发布时出现此错误
C:\Program Files (x86)\Microsoft Visual Studio17\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.
在网上寻找解决方案时,我遇到了同样问题的人,但他们实际上有很多目标,但是,就我而言,我不确定为什么会得到它。
有什么想法吗?
.csproj
模板 (https://github.com/dotnet/sdk/issues/251) 发生了变化。
而不是 <TargetFrameworks>
你需要使用 <TargetFramework>
:
<PropertyGroup>
<TargetFramework>net462</TargetFramework>
<RuntimeIdentifier>win7-x64</RuntimeIdentifier>
</PropertyGroup>
使用 Visual Studio 2017,我使用 .NET Framework 创建了一个 ASP.NET 核心站点。
(我没有 project.json
,我有一个带有 .cproj
的 VS2017 项目)
我的目标是 x64 Windows 2008R2。我的 .cproj
的开头如下所示:
<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>
...
但是,虽然我只针对 .NET 4.6.2,但当我尝试发布时出现此错误
C:\Program Files (x86)\Microsoft Visual Studio17\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.
在网上寻找解决方案时,我遇到了同样问题的人,但他们实际上有很多目标,但是,就我而言,我不确定为什么会得到它。
有什么想法吗?
.csproj
模板 (https://github.com/dotnet/sdk/issues/251) 发生了变化。
而不是 <TargetFrameworks>
你需要使用 <TargetFramework>
:
<PropertyGroup>
<TargetFramework>net462</TargetFramework>
<RuntimeIdentifier>win7-x64</RuntimeIdentifier>
</PropertyGroup>