为什么IIS 8.0学习版在Visual Studio 2012中重命名后使用旧项目名称



在一些命名混乱之后,我的团队决定重命名一些项目和项目中所有现有代码文件的名称空间。(在Visual Studio 2012中)

我们已经改变了:

  • 项目名称
  • 项目属性中的程序集名称、默认命名空间、标题和产品条目
  • 重命名的每个项目中每个代码文件的名称空间
  • 修改后的命名空间的所有using语句
  • 清除/bin目录中的旧.dll文件(以便路由引擎找不到多个控制器)
  • 实际文件夹本身,需要删除项目并将其重新添加到解决方案中(以及重新引用重命名的项目)

尽管如此,IIS 8.0 Express仍然坚持使用旧的项目名称作为站点名称(在本地调试时)。我该怎么解决这个问题?

编辑:真正的问题是:IIS 8.0 Express如何确定站点名称

这是一个网站的.csproj文件的剪辑

<ProjectExtensions>
  <VisualStudio>
    <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
      <WebProjectProperties>
        <UseIIS>True</UseIIS>
        <AutoAssignPort>True</AutoAssignPort>
        <DevelopmentServerPort>52143</DevelopmentServerPort>
        <DevelopmentServerVPath>/</DevelopmentServerVPath>
        <IISUrl>http://localhost:53177/</IISUrl>
        <NTLMAuthentication>False</NTLMAuthentication>
        <UseCustomServer>False</UseCustomServer>
        <CustomServerUrl>
        </CustomServerUrl>
        <SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
      </WebProjectProperties>
    </FlavorProperties>
  </VisualStudio>
</ProjectExtensions>

网站名称没有任何内容。

问题根本不在项目中。

在applicationhost.config文件(iis.net链接)中,通常在中

(user-dir)My DocumentsIISExpressconfigapplicationhost.config

有网站的设置。只需更改网站的名称属性。

       <site name="MvcApplication1" id="3">
            <application path="/" applicationPool="Clr4IntegratedAppPool">
                <virtualDirectory path="/" physicalPath="(whateverpath)My DocumentsVisual Studio 2012ProjectsMvcApplication1MvcApplication1" />
            </application>
            <bindings>
                <binding protocol="http" bindingInformation="*:57733:localhost" />
            </bindings>
        </site>

您还必须在csproj文件和sln文件(基本上是VS使用的具有文件扩展名的xml文件)中找到并更改这些名称。

首先也是最重要的一点,备份你所有的东西,以防万一。接下来,在csproj/sln文件中对旧名称进行文本搜索(希望它们没有被称为"if")。更改名称,然后尝试启动。

我不知道有什么工具或自动化的方法可以做到这一点,但如上所述,我已经成功地通过手工完成了这一点。

是否重新配置了IIS Express?在项目属性的web选项卡上,单击"创建虚拟目录"

最新更新