[英]Visual Studio 2015 resetting web project to use IIS Express
I have a web project in VS2015 that I want to run on Local IIS. 我在VS2015中有一个我想在本地IIS上运行的Web项目。 I set this up in the project properties and it works correctly, but whenever I close and reopen Visual Studio it always resets the project to use IIS Express. 我在项目属性中设置它并且它可以正常工作,但每当我关闭并重新打开Visual Studio时,它总是重置项目以使用IIS Express。
EDIT: this happens when I close and reopen the solution, even if Visual Studio has stayed open. 编辑:当我关闭并重新打开解决方案时,即使Visual Studio保持打开,也会发生这种情况。
Why is this happening, and how can I change it? 为什么会发生这种情况,我该如何改变呢? (Note - other users are working on the same project so I don't want to store my Local IIS settings in the project file as I assume this would overwrite their settings when they got the latest version of the code.) (注意 - 其他用户正在处理同一个项目,所以我不想将我的本地IIS设置存储在项目文件中,因为我认为这会在他们获得最新版本的代码时覆盖他们的设置。)
I edited the .csproj.user file and this fixed the problem. 我编辑了.csproj.user文件,这解决了这个问题。 I changed <UseIISExpress>true</UseIISExpress>
to <UseIISExpress>false</UseIISExpress>
and left everything else the same. 我将<UseIISExpress>true</UseIISExpress>
更改为<UseIISExpress>false</UseIISExpress>
并将其他所有内容保留为相同。
I still don't know why doing this through the UI didn't save, if anyone else can explain it I'll happily accept their answer. 我仍然不知道为什么通过用户界面这样做没有保存,如果其他人可以解释它我会很乐意接受他们的答案。
NibblyPig pointed out in their comment that: NibblyPig在评论中指出:
it appears that if you don't change the URL then it doesn't save the setting. 看来,如果您不更改URL,则它不会保存设置。 So I changed my Project Url, pressed save, then changed it back and pressed save again and it updated the file. 所以我更改了我的Project Url,按了save,然后将其更改回来并再次按下save并更新了文件。
I'm just putting this as an answer so it's easier to find, but full credit to NibbyPig for finding this. 我只是把它作为一个答案,所以它更容易找到,但NibbyPig完全赞同这一点。
Delete the file projectName.csproj.user
. 删除文件projectName.csproj.user
。 User specified preferences in this file overwrite the project settings. 此文件中用户指定的首选项会覆盖项目设置。
If you don't save settings how would you expect to persist it and be available when next time you open project? 如果您不保存设置,您希望如何保留它并在下次打开项目时可用? I understand your concern that your settings shouldn't affect other team members who are working on same project. 我理解您担心您的设置不应影响正在处理同一项目的其他团队成员。 Your concern can be taken care if you follow below steps. 如果您按照以下步骤操作,则可以小心谨慎。 Whatever settings you will do will remain local and applicable to you only and other team members will not get impacted. 无论您做什么设置都将保留在本地并且仅适用于您,其他团队成员不会受到影响。
Click Save button in toolbar. 单击工具栏中的保存按钮。
This way your settings will be stored in xxxx.user file and not in project file. 这样,您的设置将存储在xxxx.user文件中,而不是存储在项目文件中。
This is what worked for me using VS 2015 Update 3. This is related to what NibblyPig said. 这对我使用VS 2015 Update 3有用。这与NibblyPig所说的有关。 But for me only worked when editing the project file directly. 但对我来说,只有在直接编辑项目文件时才有效。
<IISUrl>
. 唯一需要更改的条目是(几乎在文件的末尾) <IISUrl>
。 There is no need to mess with <UseIISExpress>
configuration, you can leave it as it is. 没有必要弄乱<UseIISExpress>
配置,您可以保持原样。 An entry for IISExpress will look similar to this one: IISExpress的条目看起来与此类似:
<IISUrl>http://localhost:123456</IISUrl>
Change it to something like this one: 把它改成这样的东西:
<IISUrl>http://localhost/your_site_in_iis</IISUrl>
Note: "your_site_in_iis" should be an existing website. 注意:“your_site_in_iis”应该是现有网站。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.