简体   繁体   English

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

[英]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.

相关问题 如何在 docker 容器中运行 asp.net 核心应用程序? - How to run an asp.net core application in docker container? 我可以进一步减少对由docker容器上的asp.net Web API应用程序运行的docker映像的依赖性 - Can I further reduce dependency on docker images to run by asp.net web api application on docker container 使用 docker 容器上的数据库部署 ASP.NET Core 应用程序 - Deploying an ASP.NET Core Application with a database that is on a docker container 为Asp.net Web应用程序设置安装补丁 - Installing patch for Asp.net web application setup 如何正确杀死 ASP.NET Core 应用程序以重新启动 docker 容器 - How to propert kill ASP.NET Core application to restart docker container 在 Docker 中运行 ASP.NET Core 应用程序时丢失文件:如何在容器运行时显示文件? - Missing files when running ASP.NET Core application in Docker: How to display files when the container is running? 如何在ASP.NET应用程序中使用qpdf设置线性化PDF(Web快速查看属性) - How to setup linearized PDF(web fast view property) using qpdf in asp.net application 如何在不使用 Visual Studio 的情况下直接在 Dockers 容器上运行 ASP.NET Core Web 应用程序 - How to run an ASP.NET Core Web Application on Dockers container directly without using Visual Studio 如何在ASP.NET Web应用程序的docker中的声纳分析中执行代码分析 - How to perform code analysis in sonarqube in docker in a ASP.NET web application 如何将 asp.net core docker 容器暴露给公共 url? - How to expose an asp.net core docker container to a public url?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM