繁体   English   中英

如何使用Docker容器设置ASP.NET Web应用程序

[英]How to setup ASP.NET Web Application with Docker container

我已按照此处找到的安装说明进行操作: https : //azure.microsoft.com/zh-cn/documentation/articles/vs-azure-tools-docker-edit-and-refresh/并创建了一个空的ASP.Net hello世界项目。 当我尝试构建项目时,我不断收到此错误:

Error   MSB3073 The command "powershell -ExecutionPolicy RemoteSigned .\Docker\DockerTask.ps1 -Build -Environment Debug -Machine 'default'" exited with code 1. HelloWorld  C:\dev\HelloWorld\src\HelloWorld\Properties\Docker.targets  37  

进一步挖掘后,我得到以下错误:

1>------ Build started: Project: HelloWorld, Configuration: Debug Any CPU ------
1>
1>  Build succeeded.
1>           0 Warning(s).
1>           0 Error(s).
1>
1>  Time elapsed 00:00:00.0958314
1>
1>  .\Docker\DockerTask.ps1 : The term '.\Docker\DockerTask.ps1' is not recognized as the name of a cmdlet, function,
1>  script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
1>  correct and try again.
1>  At line:1 char:1
1>  + .\Docker\DockerTask.ps1 -Build -Environment Debug -Machine 'default'
1>  + ~~~~~~~~~~~~~~~~~~~~~~~
1>      + CategoryInfo          : ObjectNotFound: (.\Docker\DockerTask.ps1:String) [], CommandNotFoundException
1>      + FullyQualifiedErrorId : CommandNotFoundException
1>
1>C:\dev\HelloWorld\src\HelloWorld\Properties\Docker.targets(37,5): error MSB3073: The command "powershell -ExecutionPolicy RemoteSigned .\Docker\DockerTask.ps1 -Build -Environment Debug -Machine 'default'" exited with code 1.
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========

我正在Windows 10 64bit上使用Visual Studios 2015。

问题是我的工作目录设置与默认设置不同。 通过使用get-location命令,我能够弄清楚工作目录在哪里,并提供该目录的相对路径。

HelloWorld\src\HelloWorld\Docker\DockerTask.ps1

雅各维奇爵士正确地指出了这一点。

该问题是由于给msbuild的文件夹路径指向错误。

要查看要修改的路径,请按照下列步骤操作:

  • 在Properties \\ Docker.targets中,

    一种。 暂时将DockerBuildCommand更改为<DockerBuildCommand>powershell get-location</DockerBuildCommand>

    临时将DockerCleanCommand更改为<DockerCleanCommand>powershell get-location</DockerCleanCommand>

    C。 运行选择了Docker构建目标的构建(而不是“ IIS Express”)。

    d。 从“输出”窗口中的跟踪输出中,它将打印出作为执行根目录的文件夹。 例如,c:\\ folder1是powershell的根执行文件夹。

    可以说DockerTask.ps1位于c:\\folder1\\MyApp\\src\\App1\\DockerTask.ps1 Properties\\Docker.targets修改DockerBuildCommand命令以指向MyApp\\src\\App1\\DockerTask.ps1 还要修改DockerCleanCommand命令以指向MyApp\\src\\App1\\DockerTask.ps1

    powershell -ExecutionPolicy RemoteSigned MyApp\\src\\App1\\DockerTask.ps1.ps1 $(配置)-机器'$(DockerMachineName)'-ClrDebugVersion VS2015U2

    powershell -ExecutionPolicy RemoteSigned MyApp\\src\\App1\\DockerTask.ps1清理-环境$(配置)-机器'$(DockerMachineName)'

    F。 重建解决方案。

这会将映像部署到docker-machine中的default docker环境。

暂无
暂无

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

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