簡體   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