stop VS2017 from editing IISExpress applicationhost.config file - iis-express

When debugging a WebAPI project in VS2017 I set up my applicationhost.config so that IISExpress is open to external requests. In my case, the url in the binding line looks like this:
<binding protocol="http" bindingInformation="*:64895:*" />
The problem I'm having is every time I close VS2017, its creating a whole new site presumably since the binding in the project properties is http://localhost:64895. So every time I open the project, I have to edit the applicationhost.config file which I didn't have to do in VS2015.
Is there a way to fix VS2017 so its not creating a new site every time?

Related

How do I fix the NuGet Package Manager not opening/working?

I have Visual Studio Professional 2019, and I'm working on debugging a project that has issues with its NuGet packages. The NuGet Package Manager button is present when right clicking the solution.
But when I click the button, nothing happens. Nothing opens. Absolutely nothing, no error code, no messagebox, no warning in the debugger. I've tried uninstalling and reinstalling my NuGet extensions, nothing changed. I uninstalled and reinstalled visual studio and made sure to enable the package manager, nothing. I restarted my computer and Visual Studio, nothing.
The thing is, I tried opening another project (this time one of my own), and the package manager works fine, which leads me to believe the guy who made this program disabled the package manager entirely, but somehow kept the button there? I don't know exactly what the hell he did, but right now I'm not able to actually work into getting the packages I need to even launch the program. I can't look at ANY part of it either until the packages are added, because Visual Studio won't display anything.
Projects and solutions can't change the Visual Studio menu options themselves. This issue might occur for you if you are missing a .sln file for your project or if it has become corrupted (you don't actually need a .sln file to open a project in Visual Studio). If you notice, Visual Studio's NuGet Package Manager option in the menu says
Manage NuGet Packages for Solution
(emphasis mine). If you don't have the .sln file and associated properties file, then Visual Studio can't do anything when you click on that menu... there is no 'Solution' (.sln file) for it to manage packages for, in essence
Check the original working repository of the code where the project was created and look for a .sln file and a .vssscc file, and copy those over to your new working repository and open the project via that .sln file, and NuGet Package Manager should open successfully now.
If you can't find them or if the working repository doesn't exist anymore, then you'll need to create a new solution in Visual Studio and import/copy all the project files into the new solution. I don't know of a way to 'rebuild' or 'recreate' a solution file and solution properties file for a project that doesn't have them anymore.
For reference, I have had this issue when running VS on a new computer and opening projects I created, so it is not necessarily some form of 'sabotage'.
Though perhaps not the case for the original question asker, one cause of the "NuGet Package Manager" just won't open issue is a syntax error in the project's packages.config file.
In my case, a merge conflict I didn't notice added merge text (the "<<<<<.." type stuff) to the config file. That lead to a silent read error, which I didn't notice until I opened the actual NuGet Package Manager Console.
This issue occurred for me when I opened a project directly. When I instead opened the project by opening a saved solution (*.sln file) that contained the project, it went away.
In my situation, the problem was duplicated targets in the Sdk Style projects.
I imported an AssemblyInfo.Pack.Common file that defined a PreBuild and PostPack target into a Sdk Style project. But these were also present in the project file itself. The solution was to remove that targets from the project file.
In my case, I was using Visual Studio 2022 and my project was targeting .NET Framework 4.6.2.
I resolved it by removing duplicate package reference in my packages.config file which happened out of merge.
From,
<package id="Microsoft.IdentityModel.Tokens" version="6.25.0" targetFramework="net462" />
<package id="Microsoft.IdentityModel.Tokens" version="6.25.1" targetFramework="net462" />
To,
<package id="Microsoft.IdentityModel.Logging" version="6.25.0" targetFramework="net462" />
This now opens the Nuget Package Manager for my project.

What is the XspParameters element that Visual Studio for Mac adds to a .csproj file?

My team has an ASP.NET project that was originally created in Visual Studio on Windows, and has only ever been developed in that environment up to this point. Today, I opened that project for the first time in Visual Studio for Mac (version 7.6 build 711), and added a new file to the project.
After doing that, while looking at the diff on the pull request, my team noticed this new addition to the .csproj file, evidently made by Visual Studio for Mac:
<MonoDevelop>
<Properties>
<XspParameters Port="8080" Address="127.0.0.1" SslMode="None" SslProtocol="Default" KeyType="None" CertFile="" KeyFile="" PasswordOptions="None" Password="" Verbose="True" />
</Properties>
</MonoDevelop>
What is this? What does it do?
Should we manually remove it, given that the application will continue to only ever be hosted in Windows environments?
(I suspect it is probably harmless? On the other hand, I'd like to understand what it is before putting a project built with that element present into production; I'm leery about the Passsword="", for example, potentially manifesting some kind of security hole.)
These are just the settings that are used when running the ASP.NET project with Mono's ASP.NET hosting server (XSP). You can remove these properties.
Testing this and it seems that these properties are added to the project if you open the Project Options dialog and then click the OK button. Ideally if the values match the defaults then this should not be added to the project file.
It would probably make sense for Visual Studio for Mac to store this information in the same way as run configurations are in the .user file instead of adding it to the main project.

VS2015 annoying message about IIS Express

I use devenv.com to build my projects from the command line. For various reasons I do not use msbuild for that.
The problem I have with VS2015 (not VS2013) is that I sometimes get a dialog like this:
The only way known to me to make it go away is open the VS 2015 GUI and build the solution there. It needs to be done just once, but it is annoying in the first place, because the command line build is stuck until OK is pressed. Plus this could happen again.
A few notes about my setup:
IISExpress. Please, do not suggest moving to IIS.
We do not use the local applicationhost.config from the .vs folder. The global one from %USERPROFILE%\Documents\IISExpress\Config is used instead. We enforce it for all the projects in all the solutions by including <UseGlobalApplicationHostFile>True</UseGlobalApplicationHostFile> in each and every project (through a common targets file).
My command line build script knows to create the web application site in the global applicationhost.config, so in VS 2013 the script could be used even if no sites were initially configured - they are configured on the fly, just like VS 2013 GUI does. However, this no longer works in VS2015 - it opens this bloody dialog.
What additional command line configuration needs to be done to avoid this dialog?
When you open VS 2015 for the solution, the first thing it does is to repopulate the applicationhost.config file inside the local .VS folder. But if you rebuild your project using Devenv.com command line, it will not automatically regenerate the .vs config file correctly.
So I agree with Lex Li, we might ignored a few inconformity. You can try to closed Visual Studio and then deleted the entries for your site in the applicationhost.config. Then opened project in Visual Studio and reconfigured everything before trying to run it. Or using devenv.com to build a new projects from the command line.
I just copied the applicationhost.config file from the project directory ...\.vs\...\configfolder to the IISExpress config folder located under %USERPROFILE%\Documents\IISExpress\config.
So I overwrote the global config applicationhost.config file, but in my case it was OK as it is the only VS project on my computer.
Careful when doing this when you've got more projects on your computer as connections may break.

Stop Visual Studio 2013 modifying the IISExpress applicationHost.config

I have a website project using Visual Studio 2013, and each time I open it, it keeps adding a new entry for the website project in applicationHost.config. I use IISExpress for my development, however I always create a custom entry to provide some specifics and I have it configured to use port 80, so I would like to not have Visual Studio make any modifications to this file.
I have gone into Tools > Options > Web Projects and unchecked "Use the 64 bit version of IIS Express for web sites and projects", closed the solution, removed the entry from applicationHost.config and re-opened the project in Visual Studio, however it still continues to add an entry to applicationHost.config and name my website project whatever that entry is named.
Is there a way to disconnect Visual Studio entirely from IISExpress? I like using it, but I want to control that service and configuration myself.
Inside the bindings section of the site section, create a new binding in addition to the localhost version like so:
<bindings>
<binding protocol="http" bindingInformation="*:21232:localhost" />
<binding protocol="http" bindingInformation="*:21232:*" />
</bindings>
After having both lines, VS stopped making new site sections.
How to: Specify a Port for the Development Server
I just tried out the method described in the above msdn article to change the port IIS express uses (didn't try 80 though).
right click the website in solution explorer, remove (won't delete files)
edit the applicationHost.config file, change the binding
"add existing web site" in Visual Studio (point to the folder of site you previously removed)
At that point it doesn't seem to create a new entry in applicationHost.config, and uses the new port.
We have the same problem here. Two days googling for a solution without success. The only solution until now is to add the website to the solution using the Local IIS option.
I ran into this trouble when I was switching from one TFS workspace to another while experimenting with VS2013. I'd updated to VS2013 from VS2012 in a new workspace, then when I was done and committed the changes, I got the latest in my original workspace and began to use it there with VS2013. Every time I loaded my web project I got the message about it editing my project file, and every time it did, it screwed up the settings.
Here's how I fixed it, after trying the other answers here. A bad .csproj.user file was the problem. I do not use this file, generally, as I have the "Apply server settings to all users (store in project file)" checkbox in the Web properties checked. But I'd used it in the past. Deleting this file, or updating it so that the settings match those I've set in the project file (i.e. setting the port, whether to use IISExpress, etc.) fixed it. I can now load my project without visual studio making (the wrong) edits to my project file every time I load.
In the project properties, I see a "Web" tab, which contains a "Servers" section that has a dropdown where you can select from the following:
IIS Express
Local IIS
External Host
I believe selecting "Local IIS" is the option you need.
If you don't want to use a local development server, you can attach to an IIS process on a local machine very easily.
There's a way to set the build output location for debug in the properties (right-click project in solution explorer and choose 'properties). If you want to do this easily the first time with no extra setup, just copy your debug build's output to your website folder that you configured in IIS.
Next, ensure you can hit the IIS site. If so, go back to Visual Studio and go to the Debug-> Attach to Process menu item. Choose 'w3wp.exe' out of the list (you may have to check 'view all processes'). You should now be able to hit breakpoints in VS.
However, you should also be able to use IIS Express with a specific port, as #Anssssss said.

Why does it say "Project with that name already opened in the solution"?

I recently migrated a VSS database to TFS 2008. Using Source Control Explorer, I got the latest version of a solution with 12 projects.
When I opened the solution in VS 2005, two of the projects were not found. I am not sure why these two projects were not found, but thought it easiest to just delete and re-add them to the solution.
When I do this, VS gives me a "A project with that name is already open in the solution." The project doesn't appear in solution explorer, and is not listed in the .sln file.
Any ideas?
I had this problem and I was able to solve it using the following steps:
Remove the project from the solution.
restart visual studio.
add the project to the solution as an existing project.
I had the same message... Seems like it comes from (.csproj) project file. Under first propertygroup there is a section named
<ProjectTypeGuids>...</ProjectTypeGuids>
which generally tells Visual Studio to handle that project in some specific way. Some Guids can be found here.
First make a backup copy of that file. Then removing that section can help you open the project as usual project. As it seems that the Visual Studio thinks that the project is not the type that is specified in the ProjectTypeGuids.
This did it for me:
remove the section <ProjectTypeGuids>...</ProjectTypeGuids> in each project
reopen each project, then save to overwrite the existing project file, finally exit
reopen the solution file
pray (optional)
If anyone uses AnkhSVN instead of TFS, it's also possible, that the .sln-file need the following lines:
GlobalSection(SubversionScc) = preSolution
Svn-Managed = True
Manager = AnkhSVN - Subversion Support for Visual Studio
EndGlobalSection
in the "Global" section.
Before anyone tries tempering with their solution- and project files, figure if you may have project dependencies outside the solution, such as IIS - and you forgot to start Visual Studio in Administrator-mode
For me, the project not loaded was because it was configured to use IIS on the local machine and I needed to start Visual Studio as an Administrator.
I have to say that removing the section <ProjectTypeGuids>...</ProjectTypeGuids> could create some problems.
In fact, such a section defines the type of the project and, if removed, could disable some features.
For example, if your project was originally defined as Smart Device (C#), after removing the aforementioned section the on-device debug may not working properly.
Delete .suo file. Build solution. Add Projects.
Unfortunately I don't know the why behind the obtuse error message, I can merely provide what steps I took to get it to go away.
In my case, I had reconfigured my local IIS (<UseIIS> not <UseIISExpress>) and it was no longer hosting the URL that was in the csproj <IISUrl> field.
Editing the .csproj file in another editor and changing that field to the new URL, followed by closing and opening the solution in VS resolved the issue.
I would try hand editing the project/solution files, they are text and pretty easy to read. You can edit the file in notepad. To open up the file as text in visual studio you need to first close the solution. Then do file->open and select the sln file, but instead of hitting the open button, press on the right side where there is an arrow and select open with.. from there you can select source code editor (text).
Somehow VS 2022 doesn't create a virtual directory anymore. I had to manually create the website in IIS
I had the same problem when i migrated a website to a web app project.
Unload the web app.
Add the existing website.
Reload the web app.
The following worked for me when I moved a project running vs2010 to another laptop.
I removed exactly the following and it worked:
<ProjecctType>Guid of sorts</ProjectType>
<SccProjectName>Svn</SccProjectName>
<SccLocalPath>Svn</SccLocalPath>
<SccAuxPath>Svn</SccAuxPath>
<SccProvider>SubversionScc</SccProvider>
For those looking for this while dealing with VSTO projects...
Be sure to have the Office Tools for Visual Studio installed in your machine before opening the project.
I solved it by changing Windows' regional settings. Instead of "English (Europe)", I used "English (United States)". Others have reported similar behaviors with changing for example from "Russian (Ukraine)" to "Russian (Russia)", etc.
-AlessandroSegala
Work For me.
Ref: http://answers.microsoft.com/en-us/windows/forum/windows_10-windows_install/customized-cultures-cannot-be-passed-by-lcid-only/26eb9d4b-7ddb-4774-8a40-7a7d84ba9277?auth=1&rtAction=1455534187354
In my case it was corrupted vbproj file. First line was missing:
<?xml version="1.0" encoding="utf-8"?>
After adding this line I had to close the solution, delete .vs folder and open again.
I got it in Visual Studio 2022 version 17.4.4.
You may also see:
Error HRESULT E_FAIL has been returned from a call to a COM
component.
when you try to reload your project.
One way to load the project (and deal with IIS directories later) is to edit the .csproj file and set UseIISExpress to true.
Replace:
<UseIISExpress>false</UseIISExpress>
with
<UseIISExpress>true</UseIISExpress>
Then you need to close your solution and open it again and the project should load.
I encountered this issue with web application projects.
When I tried to reload the projects, the VS2022 output said something like :
"The project is configured to use IIS. Unable to find the server
'{site_url}' on the local computer. Ensure that the local IIS is
configured to handle secure communications."
Which is pretty clear. Indeed, in my case, this was caused by my website https binding that just vanished for no reason (it happened to me several times, looks like a bug with Windows 11 & IIS 10). Things got fixed when I got my https binding back (projects could load norammly).
In VS 2022 to open a legacy web project I had to:
Remove from Solution
Change framework version from 4.6.x to <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> in from csproj
Remove <OutputType>Library</OutputType> from csproj
Close Solution and open it again (!!!)
Add project to the sln again.

Resources