如何使用Docker容器来设置ASP.NET Web应用程序
我已经按照这里find的安装说明: https : //azure.microsoft.com/en-us/documentation/articles/vs-azure-tools-docker-edit-and-refresh/并提出了一个空的ASP.Net你好世界项目。 当我尝试构build我的项目时,我不断收到此错误:
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 64位上使用Visual Studios 2015。
问题是我的工作目录设置不同于默认设置。 通过使用get-location命令,我能够找出工作目录的位置,并为其提供该目录的相对path。
HelloWorld\src\HelloWorld\Docker\DockerTask.ps1
爵士杰克维奇正确地指出。
这个问题是由于给msbuild一个错误的文件夹path。
要检查修改的path,请按照下列步骤操作:
-
在Properties \ Docker.targets中,
一个。 暂时将DockerBuildCommand更改为
<DockerBuildCommand>powershell get-location</DockerBuildCommand>
。湾 暂时将DockerCleanCommand更改为
<DockerCleanCommand>powershell get-location</DockerCleanCommand>
。C。 运行生成Docker生成目标select(而不是'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
$(Configuration)-Machine'$(DockerMachineName)'-ClrDebugVersion VS2015U2powershell -ExecutionPolicy RemoteSigned
MyApp\src\App1\DockerTask.ps1
清洗 – 环境$(configuration) – 机器'$(DockerMachineName)'F。 重build解决scheme。
这会将映像部署到docker-machine中的default
docker环境中。