Docker 容器中的 Nuget 还原 [英] Nuget Restore in a Docker Container

查看:20
本文介绍了Docker 容器中的 Nuget 还原的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 docker 容器中运行 nuget restore mySolution.sln.

I am trying run nuget restore mySolution.sln in a docker container.

在大多数情况下,它似乎工作得很好.软件包似乎恢复正常,但在恢复之前,它显示此错误:

For the most part it seems to work just fine. The packages seem to restore fine, but before they do, it shows this error:

C:srcmyProjectmySolution.csproj(317,11): 
error MSB4226: The imported project "C:Program Files (x86)Microsoft Visual Studio2017BuildToolsMSBuildMicrosoftVisualStudiov15.0WebApplicationsMicrosoft.WebApplication.targets" was not found. 

Also, tried to find "WebApplicationsMicrosoft.WebApplication.targets" in the fallback search path(s) for $(VSToolsPath) 
      - "C:Program Files (x86)MSBuildMicrosoftVisualStudiov15.0" . 

These search paths are defined in "C:Program Files (x86)Microsoft Visual Studio2017BuildToolsMSBuild15.0inmsbuild.exe.Config". Confirm that the path in the  declaration is correct, and that the file exists on disk in one of the search paths.

根据我的阅读,这意味着我需要 nuget 包 MSBuild.Microsoft.VisualStudio.Web.targets.我做了一个nuget安装,但错误并没有消失.(它只是将它放在我运行它的任何地方.我尝试将它与我的解决方案放在包文件夹中.两者都没有任何效果.)

From what I read, this means I need the nuget package MSBuild.Microsoft.VisualStudio.Web.targets. I did a nuget install of that, but the error does not go away. (It just drops it where ever I run it. I tried putting it with my solution and in the packages folder. Neither had any effect.)

如何使用命令行工具修复此错误?(没有 GUI,因为这是 docker 容器).

How can I fix this error using command line tools? (No GUI because this is a docker container).

推荐答案

我假设您要构建的是一个 Web 应用程序,但是您还没有在构建工具包中安装相应的工作负载.这就是原因这个问题的.(同意imps)

I assume what you're trying to build is a web-application, but you haven't installed corresponding workloads in your build tools package.And that's the cause of this issue. (Agree with imps)

开始菜单中打开Visual Studio Installer,你可以修改你的msbuild包的工作负载:

Open the Visual Studio Installer in Start menu and you can modify the workloads of your msbuild package:

我只使用 msbuild 构建工具包在服务器中构建 C++ 桌面项目,所以我只安装 Visual C++ 构建工具工作负载.对于您来说,您必须安装 Web 应用程序的构建工具,以便您可以获得构建 Web 应用程序所需的文件.

I only use the msbuild build tools package to build C++ desktop projects in server, so I only install the Visual C++ build tools workload. For you, you have to install the build tools for Web applications so that you can get the necessary files to build web-applications.

更新:

error: The imported project "C:Program Files (x86)Microsoft Visual Studio2017BuildToolsMSBuildMicrosoftVisualStudiov15.0WebApplicationsMicrosoft.WebApplication.targets" was not found. 

安装 Web 开发构建工具 后,我现在在路径 C:Program Files (x86)Microsoft Visual 中获得了新创建的 WebApplications 文件夹Studio2017BuildToolsMSBuildMicrosoftVisualStudiov15.0.

After I install the Web development build tools, I now get the newly created WebApplications folder in path C:Program Files (x86)Microsoft Visual Studio2017BuildToolsMSBuildMicrosoftVisualStudiov15.0.

这篇关于Docker 容器中的 Nuget 还原的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆