visual studio 2017 web deploy emply database connection strings - c#

I have a C# app that was initially written in VS2015 but earlier this year we upgraded to 2017. I opened the project in VS2017 months ago and kept going. There is a long story that I don't think is relevant here about some serious weirdness that happened to that app related to css and js deployment in the last 4-5 business days. Suffice it to say that I threw up my hands and created a new c#/.net framework project in VS2017 and copied the main source files and the web.config file over; re-made my models; brought in the necessary nuget packages, etc. I built the project without issue.
I am now trying to do a Web Deploy. This should be a simple thing. the "release" version of the project needs to have the relevant files transferred to an IIS dev server. I did this many, many times with VS2017 before the weirdness. It worked.
Now, with a .Net Framework project created from scratch in VS2017 Web Deploy fails with the error
The 'Connection String' argument cannot be null or empty.
This is peculiar since when I created the Deploy profile I told it not to deploy databases. It appears, however, that unchecking the "Use this connection string at runtime" boxes in the Web Deply settings is ignored. Unchecking the boxes and saving the edits then re-editing the settings shows the boxes checked. Unchecking, saving, exiting VS and re-entering has the boxes checked.
I see the connection elements in the Release.pubxml file generated
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
...
<PublishDatabaseSettings>
<Objects xmlns="">
<ObjectGroup Name="MsSQLEntities" Order="1" Enabled="False">
<Destination Path="" />
<Object Type="DbCodeFirst">
<Source Path="DBContext" DbContext="myapp.Models.MsSQLEntities, My App" Origin="Configuration" />
</Object>
</ObjectGroup>
<ObjectGroup Name="MySQLEntities" Order="2" Enabled="False">
<Destination Path="" />
<Object Type="DbCodeFirst">
<Source Path="DBContext" DbContext="myapp.Models.MySQLEntities, My App" Origin="Configuration" />
</Object>
</ObjectGroup>
</Objects>
</PublishDatabaseSettings>
</PropertyGroup>
<ItemGroup>
<MSDeployParameterValue Include="MySQLEntities-Web.config Connection String">
<UpdateDestWebConfig>False</UpdateDestWebConfig>
</MSDeployParameterValue>
<MSDeployParameterValue Include="MsSQLEntities-Web.config Connection String">
<UpdateDestWebConfig>False</UpdateDestWebConfig>
</MSDeployParameterValue>
</ItemGroup>
</Project>
I have looked at the Release.pubxml file from an earlier copy that was made of this project. It would have been made bt vs2015. Eventhough I know that I unchecked the DB connection boxes above; this file has full connection strings in it.
I have now tried copying the "old" pubxml file to the new project but nothing changes.
Oh, just noticed in the pubxml file above it talks about "DbCodeFirst". I am pretty sure this was all DB first.
Help?
EDIT
sorry, somehow duplicated a section in the original

Found the issue. Something in the way the MySQL libs set themselves up puts a lot of bogus chaff in the web.config file. All the entries mention connectionStringName="LocalMySqlServer". I commented out all those blocks and it's working again.
Also, even though web publish threw up a popup to tell me it had failed, it really hadn't. It actually published to the remote dev site. Running the app over there dumped enough error hints to find the info above.

Related

aspNetCore 2.2.0 - AspNetCoreModuleV2 error

After updating my project to "Microsoft.AspNetCore.All" 2.2.0, I get an error when running in IIS, but not when running in Visual Studio.
HTTP-Fehler 500.21 - Internal Server Error
Der Handler "aspNetCore" weist das ungültige Modul "AspNetCoreModuleV2" in der Modulliste auf.
I don't know what is causing this and the www does not seem to have an answer.
Maybe someone facing the same thing and has a solution
You just need to install this package below. After that you can use the AspNetCoreModuleV2 :)
https://dotnet.microsoft.com/download/thank-you/dotnet-runtime-2.2.2-windows-hosting-bundle-installer
When installing, please notice to install as administrator. As part of the installation the applicationHost.config file will be updated to include AspNetCoreModuleV2 and its dll. this is one of the reasons why it's important to run installation with admin privilege.
I have the same issue. it is something wrong with AspNetCoreModuleV2:
modules="AspNetCoreModuleV2"
The site is working when I change the modules to AspNetCoreModule in the web.config:
modules="AspNetCoreModule"
I'm publishing to a shared host so not able to install the package mentioned.
Changing AspNetCoreModuleV2 to AspNetCoreModule is the solution recommended by my host and seems to work.
Next task is working out how to get VS to write the correct thing so I don't have to edit web.config every time.
Modify your .csproj file with code below, then republish.
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AspNetCoreModuleName>AspNetCoreModule</AspNetCoreModuleName>
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
</PropertyGroup>
Refer: how-to-install-and-use-the-aspnet-core-module
Not an answer, but an important and critical component of all the answers here. MAKE SURE YOU RESTART IIS after installing the modules needed.
You can Add web.config with Solution Explorer -> Add -> New Item -> Search for "config" -> Add Web Configuration File. This will add web.config in your project with default content
copy ur published config xml in to new webconfig and change modules="AspNetCoreModuleV2" to modules="AspNetCoreModule"
This error message is specific to permissions. However when you encounter this error with no relevant logs or messages, make sure you have the Hosting Bundle for your dotnet version installed in your Windows machine along with the Runtime bundle. I had to installed hosting bundle for iis to get this error sorted out although mine was not related to permissions.
https://dotnet.microsoft.com/en-us/download/dotnet

Can't publish ASP.Net Razor app because of locked file in VS2017

I have an ASP.Net Razor web site that I've been enhancing and successfully publishing to our intranet for the last couple of years. I recently started using VS2017 with it without any problems. Today, I encountered an error when I tried to publish it:
Error Copying file .vs\ETF\v15\Server\sqlite3\db.lock to C:\Users\myId\AppData\Local\Temp\WebSitePublish\mySite-1436350714\obj\Debug\Package\PackageTmp\.vs\ETF\v15\Server\sqlite3\db.lock failed. The process cannot access the file '.vs\ETF\v15\Server\sqlite3\db.lock' because it is being used by another process.
I tried restarting my machine and renaming db.lock in the .vs\ETF\v15\Server\sqlite3 folder, but when I start the project in VS and try to publish it again, it recreates db.lock file (with current timestamp), and gives me the same error. I use SQL Server in the app, but have no idea where the sqlite3 reference is coming from. Also there is no db.lock file in the destination directory.
Any ideas would be greatly appreciated as my online searches have been fruitless.
I ran into this exact problem after updating to Visual Studio 2017 Community from Visual Studio 2015 Pro. I also changed PCs in the upgrade. I found the solution to be the .vs folder wasn't hidden. Change the attribute hidden for the entire folder and subfolders and that should fix your problem.
Need to add this line in your publish profile (blabla.pubxml file):
<ExcludeFoldersFromDeployment>.vs</ExcludeFoldersFromDeployment>
Like the following:
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
...
<ExcludeFoldersFromDeployment>.vs</ExcludeFoldersFromDeployment>
...
</PropertyGroup>
</Project>
To resolve this issue, simply uncheck the "Allow precompiled site to be updatable" option in your publish profile settings. Then I shutdown VS and deleted the .VS/project name folder. Started VS back up and published the web app.

Microsoft.WebApplication.targets was not found MSBuild [duplicate]

Trying to build my project on the build server gives me the following error:
Microsoft (R) Build Engine Version 4.0.30319.1
error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\TeamData\Microsoft.Data.Schema.SqlTasks.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
I solved this problem a few months ago, with installing Visual Studio 2010 on the Build Server. But now I'm setup a new server from scratch, and I want to know if there any better solution to solve this issue.
To answer the title of the question (but not the question about the output you're getting):
Copying the following folder from your dev machine to your build server fixes this if it's just web applications
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications
Remove x86 according to how your build breaks. If you have other project types you will probably need to copy the entire msbuild folder.
The solution would be to install redistributable packages on build server agent. It can be accomplished multiple ways, out of which 3 are described below. Pick one that suits you best.
Use installer with UI
this is the original answer
Right now, in 2017, you can install WebApplication redists with MSBuildTools. Just go to this page that will download MSBuild 2017 Tools and while installation click Web development build tools to get these targets installed as well:
This will lead to installing missing libraries in C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0\WebApplications by default
Use command line
disclaimer I haven't tested any of the following proposals
As #PaulHicks and #WaiHaLee suggested in comments, it can also be installed in headless mode (no ui) from CLI, that might actually be preferable way of solving the problem on remove server.
Solution A - using package manager (choco)
choco install visualstudio2017-workload-webbuildtools
Solution B - run installer in headless mode
Notice, this is the same installer that has been proposed to be used in original answer
vs_BuildTools.exe --add Microsoft.VisualStudio.Workload.WebBuildTools --passive
Building and publishing WAPs is not supported if VS is not installed. With that said, if you really do not want to install VS then you will need to copy all the files under %ProgramFiles32%\MSBuild\Microsoft\.
You will need to install the Web Deploy Tool as well. I think that is it.
UPD: as of VS2017, there is workload in Build Tools that eliminates this problem completely. See #SOReader answer.
If you'd prefer not to modify anything on build server, and you still want the project to build right out of source control, it might be a good idea to put the required binaries under source control. You'll need to modify the imports section in your project file to look like this:
<Import Project="$(SolutionDir)\BuildTargets\WebApplications\Microsoft.WebApplication.targets" />
<Import Condition="false" Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
The first line is the actual import from the new location that is relative to the solution directory. The second one is a turned-off version (Condition="false") of the original line that allows for Visual Studio to still consider your project to be a valid Web Application Project (that's the trick that VS 2010 SP1 does itself).
Don't forget to copy the C:\Program Files (x86)\Microsoft\VisualStudio\v10.0\WebApplications to BuildTargets folder under your source control.
You can also use the NuGet package MSBuild.Microsoft.VisualStudio.Web.targets, referencing them within your Visual Studio project(s), then change your references as Andriy K suggests.
Based on this post here you can simply download the Microsoft Visual Studio 2010 Shell (Integrated) Redistributable Package and the targets are installed.
This avoids the need to install Visual Studio on the build server.
I have just tried this out now, and can verify that it works:
Before:
error MSB4019: The imported project "C:\Program Files
(x86)\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets"
was not found. Confirm that the path in the declaration is
correct, and that the file exists on disk.
After the install:
[Builds correctly]
This is a far better solution than installing Visual Studio on a build server, obviously.
The latest Windows SDK, as mentioned above, in addition to the "Microsoft Visual Studio 2010 Shell (Integrated) Redistributable Package" for Microsoft.WebApplication.targets and "Microsoft Visual Studio Team System 2008 Database Edition GDR R2" for Microsoft.Data.Schema.SqlTasks.targets should alleviate the need to install Visual Studio 2010. However, installing VS 2010 maybe actually be less overall to download and less work in the end.
Add dependency through NuGet & set a Build Parameter
Goal: no changes / installs necessary to the build agents
I have taken a hybrid approach to the NuGet approach by Lloyd here, which was based off of the committing binary dependencies solution by Andrik.
The reason why is I want to be able to add new build agents without having to pre-configure them with items such as this.
On a machine with Visual Studio, Open the solution; ignore that the web project fails.
In the NuGet package manager, add MSBuild.Microsoft.VisualStudio.Web.targets, as Lloyd mentioned.
This will resolve the binaries to [solution]\packages\MSBuild.Microsoft.VisualStudio.Web.targets.nn.n.n.n\tools\VSToolsPath\
You can copy these to a references folder & commit,
Or just use them where they are at. I chose this, but I'm going to have to deal with the version number in the path later.
In Version 7, I did the following. This may not have been necessary, and based on the comments is definitely not needed now. Please see the comments below.
Next, in your TeamCity build configuration, add a build Paramenter for env.VSToolsPath and set it to the VSToolsPath folder; I used ..\packages\MSBuild.Microsoft.VisualStudio.Web.targets.11.0.2.1\tools\VSToolsPath
When building on the build/CI server, turn off the import of Microsoft.WebApplication.targets altogether by specifying /p:VSToolsPath=''. This will, essentially, make the condition of the following line false:
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
This is how it's done in TeamCity:
If you migrate Visual Studio 2012 to 2013, then open *.csproj project file with edior.
and check 'Project' tag's ToolsVersion element.
Change its value from 4.0 to 12.0
From
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" ...
To
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" ...
Or If you build with msbuild then just specify VisualStudioVersion property
msbuild /p:VisualStudioVersion=12.0
Solution Source
It seems the new version of msbuild does not ship with Microsoft.WebApplication.targets. To fix you need to update your csproj file as so:
1) Edit the web app csproj (right click). Find the section in the csproj towards the bottom concerning build tools. It should look like so.
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
2) You need to add one VSToolsPath line below the VisualStudioVersion tag so it looks like so
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<!--Add the below line to fix the project loading in VS 2017 -->
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<!--End -->
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
Reference link:
https://alastaircrabtree.com/cannot-open-vs-2015-web-project-in-vs-2017/
This is all you need. Only 103MB. Don't install everything
I have found this on MS connect:
Yes, you need to install Visual Studio
2010 on your build machine to build
database projects. Doing so does
not require an additional license of
Visual Studio.
So, this is the only option that I have for now.
Anyone coming here for Visual Studio 2017. I had the similar issue and couldn't compile the project after update to 15.6.1.
I had to install MSBulild tools but still the error was there.
I was able to fix the issue by copying the v14.0 folder from C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio to the same folder as v15.0 and that resolved all the errors.
So now my folder structure looks like below, where both folders contain the same content.
If you are using MSBuild, as in the case of a build server, what worked for me is:
Change the following:
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
to:
<Import Project="$(MSBuildBinPath)\Microsoft.VisualBasic.targets" />
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
My Msbuild command is: *"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" solution.sln /p:Configuration=Debug /p:Platform="Any CPU"*
Hope this helps someone.
My solution is a mix of several answers here.
I checked the build server, and Windows7/NET4.0 SDK was already installed, so I did find the path:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets`
However, on this line:
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" />
$(MSBuildExtensionsPath) expands to C:\Program Files\MSBuild which does not have the path.
Therefore what I did was to create a symlink, using this command:
mklink /J "C:\Program Files\MSBuild\Microsoft\VisualStudio" "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio"
This way the $(MSBuildExtensionsPath) expands to a valid path, and no changes are needed in the app itself, only in the build server (perhaps one could create the symlink every build, to make sure this step is not lost and is "documented").
I fixed this by adding
/p:VCTargetsPath="C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\V120"
into
Build > Build a Visual Studio project or solution using MSBuild > Command Line Arguments
I tried a bunch of solutions, but in the end this answer worked for me: https://stackoverflow.com/a/19826448/431522
It basically entails calling MSBuild from the MSBuild directory, instead of the Visual Studio directory.
I also added the MSBuild directory to my path, to make the scripts easier to code.
I was having this issue building a SQL Server project on a CI/CD pipeline. In fact, I was having it locally as well, and I did not manage to solve it.
What worked for me was using an MSBuild SDK, capable of producing a SQL Server Data-Tier Application package (.dacpac) from a set of SQL scripts, which implies creating a new project. But I wanted to keep the SQL Server project, so that I could link it to the live database through SQL Server Object Explorer on Visual Studio. I took the following steps to have this up and running:
Kept my SQL Server project with the .sql database scripts.
Created a .NET Standard 2.0 class library project, making sure that the target framework was .NET Standard 2.0, as per the guidelines in the above link.
Set the contents of the .csproj as follows:
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="MSBuild.Sdk.SqlProj/1.0.0">
<PropertyGroup>
<SqlServerVersion>Sql140</SqlServerVersion>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
</Project>
I have chosen Sql140 as the SQL Server version because I am using SQL Server 2019. Check this answer to find out the mapping to the version you are using.
Ignore the SQL Server project on build, so that it stops breaking locally (it does build on Visual Studio, but it fails on VS Code).
Now we just have to make sure the .sql files are inside the SDK project when it is built. I achieved that with a simple powershell routine on the CI/CD pipeline that would copy the files from the SQL Server project to the SDK project:
Copy-Item -Path "Path.To.The.Database.Project\dbo\Tables\*"
-Destination (New-item -Name "dbo\Tables" -Type Directory -Path "Path.To.The.DatabaseSDK.Project\")
PS: The files have to be physically in the SDK project, either in the root or on some folder, so links to the .sdk files in the SQL Server project won't work. In theory, it should be possible to copy these files with a pre-build condition, but for some obscure reason, this was not working for me. I tried also to have the .sql files on the SDK project and link them to the SQL Server project, but that would easily break the link with the SQL Server Object Explorer, so I decided to drop this as well.
In case if you're trying to deploy a project using VSTS, then issue might be connected with checking "Hosted Windows Container" option instead of "Hosted VS2017"(or 18, etc.):
I fixed this by running the build in a docker container, specifically dotnet/framework/sdk. It includes the VS build tools.
Creating a new project and copying over the settings should probably provide the best guidance in what to do. This is what it looks like on mine
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
In my case, It was just a Port-Block.
After installation of MSBuild tools from Microsoft, define the MSBuild path in the environment variable, so that it can be run from any path.
Edit the .csproj file in any notepad editor such as notepad++, and comment the
Check for the following elements,
-->
Make sure you use import only once, choose whichever works.
Make sure you have the following folder exists on the drive, "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0" or whichever version is referenced by MSBuild target at "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\WebApplications\Microsoft.WebApplication.targets"
From the command prompt, run the following command, to check
C:>msbuild "C:\\DotnetCi.sln" /p:Configuration=Release /p:UseWPP_CopyWebApplication=true /p:PipelineDependsOnBuild=false
choose /p switch as appropriate, refer to enter link description here
enter image description here

Visual Studio 2013 error creating Web API project: The element <#text> beneath element <Project> is unrecognized

I have a problem with my Visual Studio installation.
To reproduce it I have created a new blank solution and then:
Add new project..
ASP.NET Web Application
Web API
Create Project
Visual Studio fails to create it an I get this message:
The element <#text> beneath element <Project> is unrecognized.
Any ideas how to fix that?
You will get such an error if csproj contains invalid XML.
I encountered this error when I accidentally removed <!-- inside csproj file and leave -->:
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
This doesn't address the OP's precise problem, but I stumbled across this question when I had a legitimate XML break. Sometimes, these are just really hard to spot errors, even with good IDEs.
I had to go through a diff of a ~~800 line XML file until I spotted a closing bracket with an extra >.
I wasn't able to spot it in VS2015, VS Code, Notepad++, and even WC3's automated checks -- it wasn't until I did a diff between the before and after when I noticed it. Sometimes the linters just don't catch stuff, or the suspiciously flagged area is so tiny, you miss it.
I had this same problem before and this is how I fixed it:
In the .csproj file I found these:
">>>>>>> HEAD"
"======="
and this:
">>>>>>> fef5434acad74bc99dccc873b9feded6484317d1"
within the file in random locations in between the tags. There were errors attached to all of them.
Once I removed them my project was able to load again.
Hope that helps!
If anyone gets this problem, it's due to an XML syntax error in the file.
For me it was when merging and all I did to fix was search "<<<" , ">>>" and "===" and I found the lines that were giving me a problem

Can't open web project because IIS Express is not installed (even though it is)

I have recently changed machines at work, and a long-standing web project now refuses to open in Visual Studio.
The error log reads: "The Web project 'xxx' is configured to use IIS Express. You must download and install IIS Express in order to load this project."
However, IIS Express is installed on this machine (contrary to what the message is saying), and both the UseIISExpress and UseIIS options are set to false in the csproj file:
<UseIISExpress>False</UseIISExpress>
...
<UseIIS>False</UseIIS>
I have tried silly things, like switching between false and False, but so far to no avail. Is there anything else I can try?
The way I found to make it work was by looking for the <ProjectExtensions/> tag and replacing it with:
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<UseCustomServer>True</UseCustomServer>
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
In the absence of a request for a suitable web server in the csproj file, it defaults to its own best guess, which in this case happens to be IIS Express. So in this case, the answer was to change the UseIIS option to True, and the project opened correctly.
<UseIIS>True</UseIIS>
I had the same issue but setting the UseIIS option to True did not work.
I had to remove the .user file in order to successfully load the project.
Hope this helps somebody because it took a while to discover this.
For us the solution was, to comment the following line of code in the project file:
<!--<IISUrl>http://localhost:56459/</IISUrl>-->
This worked (even if UseIIS was set to true).
Plattform: Windows 10, VS 2017
VS opened the project after deleting the IIS URL entry.
look for e.g.
<IISUrl>http://localhost:49934/</IISUrl>"
As Rob Lyndon was saying, insert <UseIIS>True</UseIIS> in the .csproj file of your solution. For me, I had to insert it right here:
<Project DefaultTargets="Build" ...>
...
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{...}">
<WebProjectProperties>
<UseIIS>True</UseIIS>
I tried setting <UseIIS> to both True and False. It didn't make a difference. Neither did changing <UseIISExpress> to true or false. I did try a variation of these settings but nothing seemed to work. I'm not saying this hasn't worked for others, but for me it hasn't.
I also deleted my .user file which again didn't fix the problem.
I even went as far as turning off IIS within Widows Features and turning it back on (Windows 7). None of it worked which was frustrating as logically it looked like it should.
The reason it didn't must have been something to do with Visual Studio 2013, at least it was in my case. I repaired VS2013 and it allowed me to load the project. I can't give any specifics as to why this was the case but after a repair and a reboot of the machine my project loads fine.
For reference as it might make a difference I have left the following in place:
<UseIISExpress>false</UseIISExpress>
....
<UseIIS>False</UseIIS>
Here is what I had to do collectively to fix this:
Change UseIISExpress to false in first PropertyGroup tag at the top of the file.
<UseIISExpress>False</UseIISExpress>
~~~
2. Add/Change UseIIS to false directly after the UseIISExpress property.
False
3. Add UseCustomServer set to True within the ProjectExtensions tag
```
<UseCustomServer>True</UseCustomServer>
4. Comment out the SaveServerSettingsInUserFile using a html comment tag.
<!--- <SaveServerSettingdInUserFile>True</SaveServerSettingsInUserFile> --->
For anybody still having this problem, I have fixed it and it's quite simple, no need to edit project files. I tried changing the <UseIIS> tag to True didn't work.
So I tried installing IIS Express 10.0, which solved the problem. Turns out you really need to install IIS Express.
I got same issue in Visual Studio 2019 Community Edition and tried all the answers given before, but in vain. Eventually, I uninstalled [ASP.NET and web development workload] from the Installer and then installed again. And it worked.
try to create a new project with the above setting and you can easily compare the .csproj files.
In visual Studio's solution explorer, right click on the project ->Property -> Web in Left hand side -> select the appropriate web server.
Compare the new .csproj file with old .csproj file and find the difference.
You can use DiffMerge.exe which will be shipped with visual studio and can be found in "drive:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\vsDiffMerge.exe"

Categories