I would like to make an API with Visual Studio and put it in a container, to be able to execute in any other computer BUT without using Visual Studio. Just running the container.
I launched Visual Studio 2019, selected a new project with the API template and I got the weatherforecast Web Application example with the controller and the WeatherForeCast class. I launch it with 'IIS' and runs perfect, I run it with 'Docker' and runs great (it create the container and I verify it via Docker Desktop). I try the app writing in Chrome/FireFox/IE: https://localhost:container_port/weatherforecast
After that, if close Visual Studio and I still have the container running, and I try again https://localhost:container_port/weatherforecast, it doesn't work.
I have checked the ports, I have also stopped the container and run it again (it start with new ports, checked in docekr desktop or with 'docker ps' with power shell) and I try again with https://localhost:container_new_port/weatherforecast and it doesn't work until I start again Visual Studio and click on 'Docker'.
It seems there is a link between the container and Visual Studio, something I don't understand because container are really to be independent from anything.
Other people has the same problem, but no solution worked for me:
How to access a website running on docker after closing the debug on Visual Studio
ASP.NET Core Docker container only responds when debugging in visual studio
why is my docker container ASP.NET core app not available after ending debugging in Visual Studio
¿Any help? If anybody ask you to build an app with visual studio BUT to be run in a container without using VS, what would you do?
Thanks for your time.
You seem to have run into an artifact of the debugging optimizations used in VS: http://aka.ms/containerfastmode. If you do a full build of the Dockerfile (right click in VS, or build from the command line [Note: the build context is the solution folder by default]) you'll get an image that works w/o VS running.
Related
I am using Visual Studio 2019 to develop a Linux executable, and the remote machine is an Ubuntu 16 VM. Right now everything works fine and debugging works like a charm, but the problem is that I need to run that program as root because its doing stuff like insmod, and right now when I start debugging with F5, it starts as the normal user.
I couldn't find any option in the Visual studio's project properties for specifying that the program needs to run as root when I press F5. Is there anyway that I can achieve this? Meaning when I start debugging it, it needs to run as root.
When I run my service fabric service in visual studio it deploys to the service fabric as expected. When I stop debugging in visual studio, visual studio then unprovisions the service fabric service.
Is there any way to prevent this behaviour? I would prefer it if visual studio left the service running in service fabric.
Thanks,
Slicc
There are two ways this can be done:
Launch your app from VS without the debugger attached (Debug -> Start Without Debugging [Ctrl+F5]). Obviously, this would require you to manually attach VS to your service processes in order to debug them. When you detach VS from the processes, VS will not remove the application in this scenario.
With your Application (.sfproj) project selected in Solution Explorer, go to the Properties window and change Application Debug Mode from "Remove" to "Auto Upgrade". This prevents VS from removing the application after debugging. However, it also causes another change in behavior in that it will automatically upgrade your application each time you launch it from VS. The added benefit of auto upgrade is that your application state will be maintained across multiple launches from VS. This may be desired or not. There is not a setting that allows you to both prevent application removal and not do an auto upgrade.
I've downloaded the latest Visual Studio 2015 CTP but am unable to get auto compilation to work. I'm trying this,
Create a web application in visual studio.
Launch it web ctrl+f5
Change some cs file
Hit f5 in the browser
Observe the change
And nothing happens. I still need to go back to VS and build to see any changes.
Anyone knows why and what I'm missing?
I have read a few threads here on StackOverflow and in all of them the problem seems that the debugger is attached. But that's not the case for me, I start the application either by ctrl+f5 or Debug -> Start without debugging.
I was able to figure out why it wasn't working. I was running Windows 10 in a VM (using Parallels on a mac), and the created project was saved in a shared drive with the path something like this,
\psf\Home\Documents\Visual Studio 2015\Projects...
And I guess the file watcher wasn't able to detect file changes and therefore the auto compile wasn't working. I have now created a new project and saved it on c: and the auto compile is working!
I am getting the error message "Unable to launch the IIS Express Web server" when trying to debug a web app in SafeMode. I am kicking off safemode with the devenv.exe /SafeMode switch and it loads my solution fine and it builds fine. But when I try and run the web app I get the aforementioned error message.
When I run VS normally (outside of SafeMode), all works as expected.
Just an FYI on why I am running in safe mode. There are times that I need to run my windows instance in a VM instead of booting into it. When this happens, trying to run VS (with all the plugins) is unbearable. So I just started using the SafeMode switch to disable all the plugins instead of turning them all off then having to turn them back on later. I did not think that turning off the plugins would make it so I could not kick off a sub process like IIS express...
Any suggestions. I am also very open to other ways to automate the launch of VS with/without plugins.
I am running Visual Studio 2013 Ultimate on Windows 8.1
Yes, currently there is a issue blocking debugging managed application under /safemode.
A possible workaround it to use "devenv.exe /rootsuffix", E.g. "devenv /rootsuffix LessPlugin". This way the Visual Studio will have no VSIX-based extensions. This won't be as clean as /safemode, but still faster if you have lots of your own VSIX installed. You may even install VSIX under the new root hive and still get it back the next time you start with the same /rootsuffix parameter.
This is the same command used to start Visual Studio if you have been writing VS extension with VSSDK. See here and here for more explanation on rootsuffix.
Why the heck does visual studio (2012 I'm using, I think previous versions did this too) load the WebDevServer for all web projects in my solution when I tell my solution to attach to another process?
If I'm attaching, obviously I don't want it to load processes because I'm debugging an already running process! Gah!
Anyone know how to make it not do this when I'm attaching to another process? This is driving me nuts because the web dev servers load up and try to acquire resources in use by the already running processes I'm trying to attach to..
I have found this occurs on some projects. If you change the project properties > Web > Servers. And the choose "Use Custom Web Server" that will ensure that Visual Studio does nothing when you attach.