Visual Studio 2017 csproj .NET 核心 netstandard2.0 未构建
Visual Studio 2017 csproj .NET CORE netstandard2.0 not building
我刚刚安装了 VS2017,并将我的 .NET 核心项目从 project.json 格式迁移到新的 csproj 格式。我想要的是针对多个框架,这样我就可以使用更小的占用空间构建一个框架依赖部署和一个自包含部署。我遵循了 MS 文档上的说明,但是当我在 TargetFrameworks 中包含 netstandard1.6 或 netstandard2.0 时,当我尝试构建项目时,我得到了一大堆 Predefined type System.Object is not defined
和 The type of namespace System could not be found
.这在使用 project.json 文件时有效。我的 csproj 是
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<VersionPrefix>1.0.0.0</VersionPrefix>
<TargetFrameworks>netcoreapp1.2;netstandard2.0</TargetFrameworks>
<AssemblyName>App</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>App</PackageId>
<RuntimeFrameworkVersion Condition=" '$(TargetFramework)' == 'netcoreapp1.2' ">1.1.1</RuntimeFrameworkVersion>-->
<NetStandardImplicitPackageVersion Condition=" '$(TargetFramework)' == 'netstandard2.0' ">1.6.1</NetStandardImplicitPackageVersion>
<RuntimeIdentifiers>win10-x64;android.21;android21-arm64;osx.10.12;rhel7.4;centos.7-x64;debian8-x64;ubuntu16.10-x64;fedora.26-x64;opensuse.42.1-x64</RuntimeIdentifiers>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute
</PropertyGroup>
<ItemGroup>
<None Remove="App.csproj.vspscc" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="System.Threading.Thread" Version="4.3.0" />
<PackageReference Include="Microsoft.NETCore.Runtime.CoreCLR" Version="1.1.0" />
</ItemGroup>
</Project>
我原来的project.json
{
"version": "1.0.0.0",
"buildOptions": {
"emitEntryPoint": true
},
"frameworks": {
"netcoreapp1.2": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.1.0"
}
}
},
"netstandard2.0": {
"dependencies": {
"NETStandard.Library": {
"version": "1.6.1"
},
"System.Threading.Thread": "4.3.0",
"Microsoft.NETCore.Runtime.CoreCLR": "1.1.0"
}
}
},
"runtimes": {
"win10-x64": {}
"ubuntu.16.10-x64": {},
"centos.7-x64": {},
"debian.8-x64": {},
"fedora.24-x64": {},
"opensuse.42.1-x64": {},
"osx10.12-x64" : {}
}
}
不确定是什么问题。我想做一些不受支持的事情吗?如果我只有 netcoreapp1.2,当我执行 dotnet publish -c Release -r win10-x64 时,我仍然会得到 FDD 输出,而不是独立的可执行文件。我觉得 json 文件更容易...我做错了什么?
当 Nuget 包未恢复时,我收到了相同的错误消息。您是否确保包已正确恢复,并且如果您 运行 "dotnet restore"?
不会出现错误
我刚刚安装了 VS2017,并将我的 .NET 核心项目从 project.json 格式迁移到新的 csproj 格式。我想要的是针对多个框架,这样我就可以使用更小的占用空间构建一个框架依赖部署和一个自包含部署。我遵循了 MS 文档上的说明,但是当我在 TargetFrameworks 中包含 netstandard1.6 或 netstandard2.0 时,当我尝试构建项目时,我得到了一大堆 Predefined type System.Object is not defined
和 The type of namespace System could not be found
.这在使用 project.json 文件时有效。我的 csproj 是
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<VersionPrefix>1.0.0.0</VersionPrefix>
<TargetFrameworks>netcoreapp1.2;netstandard2.0</TargetFrameworks>
<AssemblyName>App</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>App</PackageId>
<RuntimeFrameworkVersion Condition=" '$(TargetFramework)' == 'netcoreapp1.2' ">1.1.1</RuntimeFrameworkVersion>-->
<NetStandardImplicitPackageVersion Condition=" '$(TargetFramework)' == 'netstandard2.0' ">1.6.1</NetStandardImplicitPackageVersion>
<RuntimeIdentifiers>win10-x64;android.21;android21-arm64;osx.10.12;rhel7.4;centos.7-x64;debian8-x64;ubuntu16.10-x64;fedora.26-x64;opensuse.42.1-x64</RuntimeIdentifiers>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute
</PropertyGroup>
<ItemGroup>
<None Remove="App.csproj.vspscc" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="System.Threading.Thread" Version="4.3.0" />
<PackageReference Include="Microsoft.NETCore.Runtime.CoreCLR" Version="1.1.0" />
</ItemGroup>
</Project>
我原来的project.json
{
"version": "1.0.0.0",
"buildOptions": {
"emitEntryPoint": true
},
"frameworks": {
"netcoreapp1.2": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.1.0"
}
}
},
"netstandard2.0": {
"dependencies": {
"NETStandard.Library": {
"version": "1.6.1"
},
"System.Threading.Thread": "4.3.0",
"Microsoft.NETCore.Runtime.CoreCLR": "1.1.0"
}
}
},
"runtimes": {
"win10-x64": {}
"ubuntu.16.10-x64": {},
"centos.7-x64": {},
"debian.8-x64": {},
"fedora.24-x64": {},
"opensuse.42.1-x64": {},
"osx10.12-x64" : {}
}
}
不确定是什么问题。我想做一些不受支持的事情吗?如果我只有 netcoreapp1.2,当我执行 dotnet publish -c Release -r win10-x64 时,我仍然会得到 FDD 输出,而不是独立的可执行文件。我觉得 json 文件更容易...我做错了什么?
当 Nuget 包未恢复时,我收到了相同的错误消息。您是否确保包已正确恢复,并且如果您 运行 "dotnet restore"?
不会出现错误