Multiple VS 2017 Projects in one Docker Container - docker

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!

Related

Docker GetServiceReferences: The given path's format is not supported

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.

Visual Studio Container Tools requires Docker to be running before building, debugging or running a containerized project

I am working on .Net core Microservices. I installed Docker Toolbox containing docker cli and kitematics. After that i created a simple (.Net core) web api project in visual studio 2017 and also enable docker support.
But when i hit F5 to run the program it shows following error and doesn't run.
Visual Studio Container Tools requires Docker to be running before building, debugging or running a containerized project.
Please review the attached image.
Visual studio error on running the project
If i build and run the project using docker cli, it's working. The problem is with visual studio 2017.
In my case I had an erroneous reference in Dependencies > Packages to Microsoft.VisualStudio.Azure.Containers.Tools.Targets
Removing the reference fixed the error.
The problem occurs because Visual studio container is unable to connect to docker for windows and solution for this is to open the visual studio 2017 from Docker CLI using following command.
/c/Program\ Files\ \(x86\)/Microsoft\ Visual\ Studio/2017/Community/Common7/IDE/devenv.exe C:\\PATH\\TO\\MY\\SOLUTION.sln
Here:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\devenv.exe
is the location of my devenv.exe file and 2nd parameter
C:\\PATH\\TO\\MY\\SOLUTION.sln
shows the path of solution file.
For further details of this solution, click Here.
In my case, this issue was caused by a disabled BIOS Virtualization. To enable Virtualization, see here. In order to check whether Virtualization is already enabled, start Task Manager > Performance > find Virtualization. If you are hosting your docker container application in full feature IIS, make sure you start Visual Studio as an Administrator.
I was getting the same error when I was trying to rebuild my solution after changing my .Net Core 2.0 application to .Net Core 2.2. As I reset my windows, there was no docker installed on my machine. To fix this all I had to do is to install the docker for desktop as I wanted to containerize my applications.
Once you install the Docker, it will ask you to enable Hyper-V and Container features. By clicking the Ok button in the pop up as preceding, will enable this features for you.
Your computer will be restarted automatically and once it is done, you should be able to see that the Virtualization is enabled in the task bar.
After this I was not facing this error.
Check shared folders inside the default virtual machine setting in Virtual box to make sure you shared the disk where you project located. By default shared only C:\Users. So alternatively you can move your project somewhere inside C:\Users folder (for example in Desktop folder)
I was facing the same issue and I resolved it by switching to IIS Express instead of Docker in debug menue on visual studio 2017

Enable Windows Identity Foundation in docker

In our current project we develop an ASP.net MVC application hosted in an docker (Docker Desktop for Windows) container using the windows server core image (https://hub.docker.com/r/microsoft/windowsservercore/). Everything is working well but now we would like to use the Windows Identify Foundation (WIF) for authentication with an ADFS.
Unfortunately, the Windows Server Core image for docker does not support the WIF feature and it cannot be installed.
Does someone have an idea how to use the WIF inside of a docker container and/or experience with installing the feature in this image?
Is their an alternative image with the feature enabled?
Similar topics without docker such as:
https://support.microsoft.com/en-us/help/3044149/you-can-t-install-windows-identity-foundation-in-windows-core
https://blogs.technet.microsoft.com/server_core/2012/05/09/configuring-the-minimal-server-interface/
Did not help.
I know this is an old question, but I recently ran into the same problem and wanted to share the resolution I was able to come up with. In my case, I was working with a legacy software solution that referenced "Microsoft.IdentityModel.dll" (installed by WIF), and it was not as easy to just switch it out to something else.
I installed WIF on my laptop (Windows 10) and then added the file to my docker image
C:\Program Files\Reference Assemblies\Microsoft\Windows Identity Foundation\v3.5\Microsoft.IdentityModel.dll
Then, add a PowerShell script to your DOCKERFILE to install that assembly into the GAC manually. Here's a good blog post showing how to do that as well:
https://www.andrewcbancroft.com/2015/12/16/using-powershell-to-install-a-dll-into-the-gac/
Hope it helps!
We could solve our problems with OWIN.
Bas Lijten posted a nice tutorial on this:
http://blog.baslijten.com/configure-claims-based-web-applications-using-owin-wsfederation-middleware/
We configured the usage of WS-Fed with Owin but did not use an Embedded STS. Instead we created a standalone identityserver instance to test the ADFS integration.
On GitHub you can find an example for such an identity server configuration:
https://github.com/IdentityServer/IdentityServer3.Samples/tree/master/source/SelfHost%20(InMem%20with%20WS-Fed)

IIS Express will not start when running copy of project on different computer

I have created a brand new ASP.NET MVC 5 project in VS2015 Enterprise (update 3). It runs as expected on that machine. However, when I copy/paste the whole project to a different machine running VS2015 community edition (update 3), the site fails to load and I get the error message:
The program '[1648] iisexpress.exe has exited with code 0 (0x0).
Here's the kicker - Creating a new ASP.NET MVC 5 project in VS community edition and copy/pasting and running it in VS2015 enterprise in the same way, however, works normally without any configuration changes. I have recreated the files in the users\documents\IISExpress folder as pointed out by other SO questions, tried changing ports, but to no avail.
EDIT: IIS immediately fails on launching, by the way. It sounds like a config issue, but I'm not sure what to check in this case.
I got the same issue, what i did is just close all the visual studio instances and in your project folder clear the .vs file(mostly it's Hidden). after that open your project.

How do i run a ServiceStack console project as a Windows Service?

I have create a ServiceStack console application that works great, but of course, I have to leave it running after triggering it from a command prompt. I want to run this as a Windows Service.
I'm reviewing this wiki page which states that you can run SS as a Windows Service.
https://github.com/ServiceStack/ServiceStack/wiki/Self-hosting
I was not totally clear on how to do this. This StarterTemplate is referenced from 2 years ago. Do I clone this project and then copy my code into it?
https://github.com/ServiceStack/ServiceStack.Examples/tree/master/src/StarterTemplates/WinServiceAppHost
The easiest way is to create a ServiceStack Windows Service Empty project in ServiceStackVS VS.NET Extension.
Otherwise you can clone the WinService project, and create a new Windows Service project from Visual Studio and copy the approach in Program.cs.
A more recent ServiceStack Windows Service project is the Razor Rockstars website running in a Windows Service Host, the template of which was based on the ServiceStack.Examples Starter template.
I use topshelf to run a servicestack console app as a windows service. It works really well for me. https://github.com/Topshelf/Topshelf

Resources