简体   繁体   English

C# 编译器,SDK 和 msbuild 用于 NET 框架

[英]C# compiler, SDK and msbuild for NET framework

When trying to build a C# code with:尝试使用以下命令构建 C# 代码时:

 "C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" project.sln
 "C:\Program Files (x86)\MSBuild\14.0\Bin\amd64\MSBuild.exe" project.sln

I get:我得到:

C:\Program Files (x86)\MSBuild\14.0\bin\amd64\Microsoft.Common.CurrentVersion.targets(1098,5): error MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.5" were not found. C:\Program Files (x86)\MSBuild\14.0\bin\amd64\Microsoft.Common.CurrentVersion.targets(1098,5):错误 MSB3644:框架“.NETFramework,Version=v4.5”的参考程序集不是成立。 To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed.要解决此问题,请为此框架版本安装 SDK 或 Targeting Pack,或者将您的应用程序重新定位到已安装 SDK 或 Targeting Pack 的框架版本。 Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies.请注意,程序集将从全局程序集缓存 (GAC) 中解析,并将用于代替引用程序集。 Therefore your assembly may not be correctly targeted for the framework you intend.因此,您的程序集可能无法正确定位于您想要的框架。

Then I installed ndp48-devpack-enu.exe coming from https://dotnet.microsoft.com/download/dotnet-framework/thank-you/net48-developer-pack-offline-installer (".NET Framework 4.8 Developer Pack") but the result is the same.然后我安装了来自https://dotnet.microsoft.com/download/dotnet-framework/thank-you/net48-developer-pack-offline-installer ndp48-devpack-enu.exe (“.NET Framework 4.8 Developer Pack” ) 但结果是一样的。

Note:笔记:

  • The installation of ".NET Framework 4.8 Developer Pack" did not seem to install its own msbuild and csc.exe.安装“.NET Framework 4.8 Developer Pack”好像没有安装自己的msbuild和csc.exe。 Is this normal or am I missing something?这是正常的还是我错过了什么? That's why I used C:\Program Files (x86)\MSBuild\14.0\Bin\amd64\MSBuild.exe that had been installed previously when installing Microsoft Visual C++ Build Tools.这就是为什么我在安装 Microsoft Visual C++ Build Tools 时使用之前安装的C:\Program Files (x86)\MSBuild\14.0\Bin\amd64\MSBuild.exe的原因。

  • I'd like to install only the minimum to build C# projects from command-line, I don't want to install Vistual Studio IDE, etc.我只想安装最低限度的从命令行构建 C# 项目,我不想安装 Vistual Studio IDE 等。

You should install .Net SDK 4.5你应该安装.Net SDK 4.5

Newer version don't support older targets较新的版本不支持较旧的目标

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM