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

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

问题描述

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

在大多数情况下,它似乎工作正常.这些软件包似乎可以恢复正常,但是在这样做之前,它会显示此错误:

C:\src\myProject\mySolution.csproj(317,11): 
error MSB4226: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0\WebApplications\Microsoft.WebApplication.targets" was not found. 

Also, tried to find "WebApplications\Microsoft.WebApplication.targets" in the fallback search path(s) for $(VSToolsPath) 
      - "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0" . 

These search paths are defined in "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\bin\msbuild.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安装,但该错误并未消失. (它只是将其放在我运行的任何位置.我尝试将其与解决方案一起放入packages文件夹中.两者都没有任何效果.)

如何使用命令行工具解决此错误?(无GUI,因为这是docker容器).

解决方案

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

Start menu中打开 Visual Studio安装程序,然后可以修改msbuild软件包的工作负载:

我仅使用msbuild构建工具包在服务器中构建C ++桌面项目,因此仅安装Visual C++ build tools workload.对您来说,您必须安装build tools for Web applications,以便获得构建Web应用程序所需的文件.

更新:

error: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0\WebApplications\Microsoft.WebApplication.targets" was not found. 

安装Web development build tools后,现在在路径C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0中获得新创建的 WebApplications 文件夹.

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:\src\myProject\mySolution.csproj(317,11): 
error MSB4226: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0\WebApplications\Microsoft.WebApplication.targets" was not found. 

Also, tried to find "WebApplications\Microsoft.WebApplication.targets" in the fallback search path(s) for $(VSToolsPath) 
      - "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0" . 

These search paths are defined in "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\bin\msbuild.exe.Config". Confirm that the path in the  declaration is correct, and that the file exists on disk in one of the search paths.

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.)

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

解决方案

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)

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

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.

Update:

error: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0\WebApplications\Microsoft.WebApplication.targets" was not found. 

After I install the Web development build tools, I now get the newly created WebApplications folder in path C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0.

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

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