简体   繁体   中英

Cannot build Visual Studio 2017 project on a clean machine

Clean Windows Server 2016 machine, I installed:

I got the following error message from MSBuild:

[GetReferenceAssemblyPaths] C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\MSBuild\\15.0\\bin\\amd64\\Microsoft.Common.CurrentVersion.targets(1124, 5): error MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.5" were not found. 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. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.

How can I solve this?

Thanks.

EDIT: Trying to install .NET Framework 4.5 I get this error:

Microsoft .NET Framework 4.5 is already a part of this operating system. You do not need to install the .NET Framework 4.5 redistributable.

Same or higher version of .NET Framework 4.5 has already been installed on this computer.

Trying to install .NET Framework 4.5.2 I get this error:

.NET Framework 4.5.2 or a later update is already installed on this computer.

When you install Visual Studio Build Tools 2017, you can choose components to install. If you run vs_buildtools.exe from cmd , it only installed minimal MSBuild toolset.

You can choose components to install via GUI:

Visual Studio生成工具2017 —各个组件


Also, you can install particular component or workload via cmd :

vs_buildtools.exe --add Microsoft.Net.Component.4.5.TargetingPack --passive

You can find workloads and component names here: Visual Studio Build Tools 2017 component directory

Detailed info about command-line parameters are here: Use command-line parameters to install Visual Studio 2017


You can consider installing only workloads required for you (with recommended components):

vs_buildtools.exe --add Microsoft.VisualStudio.Workload.MSBuildTools --add Microsoft.VisualStudio.Workload.WebBuildTools --includeRecommended --passive

or all of them

vs_buildtools.exe --allWorkloads --includeRecommended --passive


You can use --quiet --wait keys instead of --passive to make installation silent.

It looks like you are running MSBuild from the wrong directory:

C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\MSBuild\\15.0\\bin\\ amd64 \\

Try and run MSBuild.exe from the bin instead and see if that works:

C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\MSBuild\\15.0\\Bin

  1. Open visual studio installer
  2. click the "modify" button under your VS installation,
  3. In the summary, expand the ".NET desktop development" category
  4. tick ".NET Framework 4-4.6 development tools
  5. You may also want to tick the rest of the optional parts.
  6. press the "modify" button to begin installation

Cannot build Visual Studio 2017 project on a clean machine

You can not install the .NET framework 4.5 on that machine, because you have a higher version of .NET framework 4.5.2 installed.

To resolve this issue, you can retarget the project to 4.5.2 or you can uninstall the .NET framework 4.5.2 and install the .NET framework 4.5.

Install .NET Framework 4 (or 4.6) in Windows Server 2016

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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