[英]How to setup ASP.NET Web Application with Docker container
I have followed the installation instructions found here: https://azure.microsoft.com/en-us/documentation/articles/vs-azure-tools-docker-edit-and-refresh/ and made an empty ASP.Net hello world project. 我已按照此处找到的安装说明进行操作: https : //azure.microsoft.com/zh-cn/documentation/articles/vs-azure-tools-docker-edit-and-refresh/并创建了一个空的ASP.Net hello世界项目。 I keep getting this error when I try to build my project:
当我尝试构建项目时,我不断收到此错误:
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
Upon further digging I get this error: 进一步挖掘后,我得到以下错误:
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 ==========
I am using Visual Studios 2015 on Windows 10 64bit. 我正在Windows 10 64bit上使用Visual Studios 2015。
The problem was my working directory was set differently than the default settings. 问题是我的工作目录设置与默认设置不同。 By using the get-location command I was able to figure out where the working directory was and give it the relative path from that directory.
通过使用get-location命令,我能够弄清楚工作目录在哪里,并提供该目录的相对路径。
HelloWorld\src\HelloWorld\Docker\DockerTask.ps1
Rightly pointed out by SirJackovich. 雅各维奇爵士正确地指出了这一点。
The issue was due to a mis-pointed folder path given to msbuild. 该问题是由于给msbuild的文件夹路径指向错误。
To check out what path to modify, follow these steps: 要查看要修改的路径,请按照下列步骤操作:
In Properties\\Docker.targets, 在Properties \\ Docker.targets中,
a. 一种。 Temporarily change DockerBuildCommand to
<DockerBuildCommand>powershell get-location</DockerBuildCommand>
. 暂时将DockerBuildCommand更改为
<DockerBuildCommand>powershell get-location</DockerBuildCommand>
。
b. 湾 Temporarily change DockerCleanCommand to
<DockerCleanCommand>powershell get-location</DockerCleanCommand>
. 临时将DockerCleanCommand更改为
<DockerCleanCommand>powershell get-location</DockerCleanCommand>
。
c. C。 Run build having Docker build target selected (instead of 'IIS Express').
运行选择了Docker构建目标的构建(而不是“ IIS Express”)。
d. d。 From the trace output in the Output window, it will print the folder which is the root for execution.
从“输出”窗口中的跟踪输出中,它将打印出作为执行根目录的文件夹。 For example, c:\\folder1 is the root execution folder for powershell.
例如,c:\\ folder1是powershell的根执行文件夹。
e. 即 Lets say DockerTask.ps1 is located in
c:\\folder1\\MyApp\\src\\App1\\DockerTask.ps1
. 可以说DockerTask.ps1位于
c:\\folder1\\MyApp\\src\\App1\\DockerTask.ps1
。 Modify the DockerBuildCommand command within Properties\\Docker.targets
to point to MyApp\\src\\App1\\DockerTask.ps1
. 在
Properties\\Docker.targets
修改DockerBuildCommand命令以指向MyApp\\src\\App1\\DockerTask.ps1
。 Also Modify the DockerCleanCommand command to point to MyApp\\src\\App1\\DockerTask.ps1
. 还要修改DockerCleanCommand命令以指向
MyApp\\src\\App1\\DockerTask.ps1
。
powershell -ExecutionPolicy RemoteSigned MyApp\\src\\App1\\DockerTask.ps1.ps1
-Build -Environment $(Configuration) -Machine '$(DockerMachineName)' -ClrDebugVersion VS2015U2 powershell -ExecutionPolicy RemoteSigned
MyApp\\src\\App1\\DockerTask.ps1.ps1
$(配置)-机器'$(DockerMachineName)'-ClrDebugVersion VS2015U2
powershell -ExecutionPolicy RemoteSigned MyApp\\src\\App1\\DockerTask.ps1
-Clean -Environment $(Configuration) -Machine '$(DockerMachineName)' powershell -ExecutionPolicy RemoteSigned
MyApp\\src\\App1\\DockerTask.ps1
清理-环境$(配置)-机器'$(DockerMachineName)'
f. F。 Rebuild the solution.
重建解决方案。
This will deploy the image to the default
docker environment within docker-machine. 这会将映像部署到docker-machine中的
default
docker环境。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.