我剛剛安裝了VS2017,並將.NET核心項目從project.json格式單向遷移到新的csproj格式。我想要的是以多個框架爲目標,這樣我就可以使用更小的佔用空間來構建Framework Depedenent Deployment和Self Contained Deployment。我遵循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是Visual Studio 2017 csproj .NET CORE netstandard2.0 not building
<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發佈-c發佈-r win10-x64我仍然得到一個FDD輸出,而不是一個獨立的可執行文件。我覺得這對json文件來說更容易...我做錯了什麼?
所以,我覺得真的很愚蠢,因爲我可以發誓我做到了,但今天早上再試一次,看起來就是這樣。謝謝! – hakenmt
太棒了!有時需要兩個額外的眼睛! – Bebben