Trying to run locally a Web MVC application using Docker. Application compiles and runs fine when Set as StartUp Project outside of the docker-compose project but fails when docker-compose is Set as StartUp Project during the build when it comes to Target DockerGetServiceReferences: with
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.VisualStudio.Docker.Compose.targets(195,5): error : The given path's format is not supported.
I have added the docker-compose through Visual Studio 2017 to an existing application as described here:
How to containerize the .NET Framework web apps with Windows Containers and Docker
I appreciate this might be quite vague so if there are any more details I could provide please let me know.
EDIT:
Adding docker-compose to just default MVC template in a new project works fine so the problem seems to be with the legacy solution. Also noticed I can't navigate docker-compose project General Properties, I get the URI formats are not supported popup error
EDIT:
Adding a brand new MVC project from the template to the solution without any references to other projects also generates the error. Could this indicate that the problem might be somewhere on the solution level?
EDIT:
I have created a new Solution file and started to migrate all the projects. This way I am successfully able to compose docker image. Once I am finished migrating all of the project I will do a comparison on .sln files and try to see what is different.
Related
On our new company laptops we are running into issues running containers in docker desktop from visual studio. We tried a bunch of things which were unsuccessful. Any help / thoughts would be great as we are running out of ideas.
.Net Core Version 6 / Asp.net Core (web api)
Running docker compose manually in cmd works and I'm able to hit the site.
Running docker compose debug profile from visual studio results in:
The output window shows "The program '' has exited with code 4294967295 (0xffffffff)."
Docker desktop shows the container running but I can't grab logs from it or hit it in the url.
WSL is fine and everything is working there.
My home machine works great and i'm able to launch and debug containers.
Faced with identical error, I was able to resolve by deleting VSDBG debugger folder:
%USERPROFILE%\vsdbg\vs2017u5
After deleting the folder start Visual Studio debugger (F5) and as a result VSDBG debugger will be recreated
Container Tools build properties https://learn.microsoft.com/en-us/visualstudio/containers/container-msbuild-properties?view=vs-2022
I have the same error when I'm trying to start 2 project simultaneously. And one project was cloned from another. So, they have the same GUIDs of projects in .sln files. After changing GUIDs all works ok.
Most of the time this error code does not provide any concrete information. In my case I had to go and find error details in logs folder. Log file is generally located at 'YourProject\bin\Debug\App_Data\Logs' location.
There was an issue with 3rd party service and it worked after fixing the service issue.
I am working on existing angular and .Net MVC application. In Web Project, I used angular and HTML pages. I want to run this application through CLI. II try to use ng serve option but it's giving above error.
I used following steps to run. Please let me know If anything is missing
1)Open Cmd prompt and went to my web project folder in which angular and package.json exist. 2)run ng serve --open in that location
getting above mentioned error.
I hope your project is a demo, because it is incorrectly managed, your app folder should be inside src folder. For using Visual Studio to make Angular App.
Here is a video tutorial/playlist to follow.
Setting up Angular 2 in Visual Studio . Here, you will see correct architecture to keep your files/folders, and method to run your application. Although, it is not my recommendation.
1). Recommendation => Use VS Code for making Angular App, and .Net Core for making Web API. For making http calls, you will have CORS at your service. Following this architecture will keep your application well-maintained.
OR
2). Recommendation => If You want to use Visual Studio for both sides, make .Net Core Web Application, there you will find ANGULAR, make project from there, and compare its architecture with your own.
You need to go inside the Angular CLI project directory to run this command.
(Probably where your package.json file exist)
I am using VS 2017 15.6.4 which is the latest version. I have a single solution that has three web projects in it:
Solution:
Web Project 1
Web Project 2
Web Project 3
I would like to add Docker support so that all the web projects end up in a single container running IIS with the following IIS site structure:
Root Site (Web Project 1)
Admin Virtual Application (Web Project 2)
Campaign Virtual Application (Web Project 3)
Is there a way to accomplish this in Visual Studio 2017? When I add Docker support it seems to be on a project by project basis. I can run each project in its own container with no issues. Will I be forced to do this outside of Visual Studio?
I had a similar question and found the following helpful. Make sure you have Docker CE installed on your machine, along with VS2017 with Docker support. In VS2017, when you do "Add->Docker Support", it should automatically include the docker-compose.yml file at the root of your solution.
https://learn.microsoft.com/en-us/dotnet/standard/microservices-architecture/multi-container-microservice-net-applications/multi-container-applications-docker-compose#step4_define_svcs_in_docker_compose_yml
There is also a sample application posted on github, linked below. Note that this follows .Net Core v2.1. I'm assuming you are using .net core and if so, note that v2.0 is end of life later this year so you should consider moving to v2.1
https://github.com/dotnet-architecture/eShopOnContainers
The github project above also has links to some free books talking more on docker and .net core. They helped me out a lot!
This is my first foyer into .Net Core and App Engines, so please forgive me if I sound uninformed.
We have a .Net Core Application that we're trying to get published to a GCP App engine (obviously). when I run dotnet publish -c Release it builds just fine without any errors. When I test the program locally it runs just fine and I'm able to access it. However whenever I try to get it on GCP I get the following error:
Updating service [default] (this may take several minutes)...
.................................................................................................................................................failed.
ERROR: (gcloud.app.deploy) Error Response: [9]
Application startup error:
Error:
An assembly specified in the application dependencies manifest (ApplicationName.deps.json) was not found:
package: 'Microsoft.AspNetCore.Mvc.Abstractions', version: '2.0.2'
path: 'lib/netstandard2.0/Microsoft.AspNetCore.Mvc.Abstractions.dll'
This assembly was expected to be in the local runtime store as the application was published using the following target manifest files:
aspnetcore-store-2.0.5.xml
Failed to deploy project WebApiDotNetCore to App Engine Flex.
We tried removing it from the dependencies JSON, and that just ended up breaking everything, so it is indeed required. It is installed in the project via nuget, so it should be included with dotnet restore. I've looked around and some sources seem to think that it's the installation of the dotnet core sdk, but I've tried it on three computers and always get the same thing.
Lastly, I should say this happens when I try to deploy through command line as well as directly through Visual Studio with the GCP SDK.
Has anyone experienced this error, or something similar? Any advice or guidance is very much appreciated.
Thanks!
-BT
OP REVISION
As an update I was able to get this resolved aside from the fact that I get a 502 error when I try to load the application. Here are the steps I took for anyone else that is looking what to do:
Pre-reqs: Docker for Windows and Google Cloud SDK installed and running. Running turned out to be a pain with Docker for Windows. Many many restarts and reinstallations.
Open the solution and ensure that the startup project is set correctly.
Right click the startup Project, and select Add > Docker Support.
Select Linux in the popup window and allow the files to be created.
When complete, the Dockerfile should appear in the preview window. Do the following:
For me the first line read: FROM microsoft/aspnetcore:2.0 AS base. Change this to FROM microsoft/aspnetcore-build:2.0 AS base.
Additionally, check to make sure that the last line has the correct .dll name. Docker for Windows will put whatever the project name is rather than the class name, so for me my final .dll names were different than the project name.
Lastly, if your project has any dependencies that are required to run but not to build, then you'll need to manually add them. For me we have a couple of XML files that needed to be put in the app folder, so I had to add COPY *.xml /app/ and put those files in the same folder as the solution file is in.
If there's anything else you need to do to the Dockerfile I highly recommend this page. It's a how-to on all Dockerfile commands written in ENGLISH! (that was my biggest problem with all of this - I have little experience with Linux and even less with Docker and everything was written in Greek for me).
Create an app.yaml file. I just used the standard:
runtime: custom
env: flex
Copy the Dockerfile found in the startup project's folder into the folder with the solution.
Initialize gcloud to the right project, then navigate to the solution folder. The type gcloud app deploy app.yaml, and follow the onscreen guide.
for me it takes about 15 minutes to deploy the GCP, so depending on the complexity of your project it may take longer, though this one is rather complex.
Now I'm trying to figure out my 502 error... I've tried what seems like everything - changing the listening port in the application, exposing the listening port on the dockerfile, trying to get GCP to open that port, and trying half a dozen different ports. It's slow-going since it's such a chore to deploy each time.
Hope this helps anyone that was like me a couple weeks ago and had never even heard of Docker!
Which version of .NET Core is this? Also, have you tried to run in Cloud Shell? Maybe that will provide more clues on what might be wrong.
It looks that you don't have the Microsoft.AspNetCore.Mvc.Abstractions library installed in your system. Using the .NET CLI, type the following command:
dotnet add package Microsoft.AspNetCore.Mvc.Abstractions --version 2.0.2
After that, to ensure the library is included, run the following:
dotnet restore
dotnet build
Try running it locally (it should work), and then use the dotnet publish -c Release command again.
I created a new .NET Core Console Application with Visual Studio 2017 (RTM). Then added Docker support and got the docker file + compose files just fine. However there are few issues with them.
Docker compose files have version 2 which makes the build fail to the following error message
Microsoft.DotNet.Docker.CommandLineClientException: client version 1.22 is too old. Minimum supported API version is 1.24, please upgrade your client to a newer version.
This can be fixed by manually changing the compose file versions to 2.1. (not sure if valid fix) Then you'll get another error message
MSB4006 There is a circular dependency in the target dependency graph involving target "DockerCleanServiceReferences".
This I have no idea how to fix. I know the error message is due to some configuration that causes circular reference (e.g. post build event that does build)
So, any resources or tips how to package the .NET Core console application into docker container manually? I'm just getting to know Docker so don't assume I know anything of it yet.
Another question, that is there some place where I could get updated versions of these Visual Studio templates or are these known issues?
It turned out the problem for me was having my DockerFile, SLN file, and CSPROJ file all in the same folder. You know how when you create a solution, it asks you if you want to create a subdirectory? If you do not, and your SLN and CSPROJ files share the same folder, inevitably the Docker files will be added to this same folder, creating the circular reference. If your SLN file lives in the directory above your CSPROJ file, the DockerFile et al will be put into your parent directory with the SLN file, and all will be well. This solved it for me.
Can you please check if your Docker for Windows is targeting Linux? It's likely you were targeting Windows container, which is not supported with .NET Core yet.
On my first spin of VS2017 with docker, using the default template, I ran in to the same issue.
I referred to this article - https://blogs.msdn.microsoft.com/containerstuff/2017/03/13/visual-studio-2017-client-version-1-22-is-too-old/
This is what worked for me - As recommended, made this changes in docker-compose project's docker-compose.ci.build.yml :
The 'version' parameter on the top of the file which was set to 2, was change to 2.1
Repeated the same changes on the other files in the project including:
docker-compose.yml
docker-compose.override.yml
docker-compose.vs.debug.yml
docker-compose.vs.release.yml
Regarding your question on how to package a .NET Core console application into a Docker image manually. The https://github.com/dotnet/dotnet-docker-samples are intended to answer that very question. Check them out. If you run into issues with them or have suggestions please log an issue (https://github.com/dotnet/dotnet-docker-samples/issues).
Thanks for the post. We will be adding Nano Server container tooling "soon". Until then, you can work with Linux containers which will give a similar experience.