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

C# 如何使用Docker容器设置ASP.NET Web应用程序,c#,asp.net,docker,visual-studio-2015,windows-10,C#,Asp.net,Docker,Visual Studio 2015,Windows 10,我已按照此处的安装说明进行了操作: 并创建了一个空的ASP.Net hello world项目。当我尝试构建我的项目时,我不断遇到此错误: Error MSB3073 The command "powershell -ExecutionPolicy RemoteSigned .\Docker\DockerTask.ps1 -Build -Environment Debug -Machine 'default'" exited with code 1. HelloWorld C:\dev\H

我已按照此处的安装说明进行了操作: 并创建了一个空的ASP.Net hello world项目。当我尝试构建我的项目时,我不断遇到此错误:

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 Studio 2015。

问题是我的工作目录设置与默认设置不同。通过使用get location命令,我能够找出工作目录的位置,并为它提供该目录的相对路径

HelloWorld\src\HelloWorld\Docker\DockerTask.ps1

SirJackovich正确地指出了这一点

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

要查看要修改的路径,请执行以下步骤:

  • 在Properties\Docker.targets中

    a。暂时将DockerBuild命令更改为
    powershell获取位置

    b。暂时将DockerClean命令更改为
    powershell获取位置

    c。运行已选择Docker生成目标的生成(而不是“IIS Express”)

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

    e。假设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
    -Build-Environment$(配置)-Machine'$(DockerMachineName)'-ClrDebugVersion VS2015U2

    powershell-ExecutionPolicy RemoteSigned
    MyApp\src\App1\DockerTask.ps1
    -Clean-Environment$(配置)-Machine'$(DockerMachineName)'

    f。重建解决方案


这将把映像部署到docker机器内的
默认
docker环境。

您好,我也面临同样的问题,您能告诉我更多详细的解决方法吗。