简体   繁体   中英

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. 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.

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.

HelloWorld\src\HelloWorld\Docker\DockerTask.ps1

Rightly pointed out by SirJackovich.

The issue was due to a mis-pointed folder path given to msbuild.

To check out what path to modify, follow these steps:

  • In Properties\\Docker.targets,

    a. Temporarily change DockerBuildCommand to <DockerBuildCommand>powershell get-location</DockerBuildCommand> .

    b. Temporarily change DockerCleanCommand to <DockerCleanCommand>powershell get-location</DockerCleanCommand> .

    c. Run build having Docker build target selected (instead of 'IIS Express').

    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.

    e. Lets say DockerTask.ps1 is located in c:\\folder1\\MyApp\\src\\App1\\DockerTask.ps1 . Modify the DockerBuildCommand command within Properties\\Docker.targets to point to MyApp\\src\\App1\\DockerTask.ps1 . Also Modify the DockerCleanCommand command to point to 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 -Clean -Environment $(Configuration) -Machine '$(DockerMachineName)'

    f. Rebuild the solution.

This will deploy the image to the default docker environment within docker-machine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM