动态设置Web应用程序项目的IISUrl [英] Dynamically setting the IISUrl of a Web Application Project

查看:245
本文介绍了动态设置Web应用程序项目的IISUrl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Web应用程序项目,希望能够在完全独立的IIS站点上进行分支和开发,而不必每次执行时都继续编辑vbproj IISUrl设置.我尝试添加一些标准属性的导入,以便可以将它们维护在WAP文件之外,但是当我在元素中引用它们时,它们并不喜欢它们.我怀疑是因为IISUrl元素是放置非msbuild信息的地方.

I have a web application project that I'd like to be able to branch and develop on a totally separate IIS site and not have to keep editing the vbproj IISUrl setting each time I do it. I have tried adding an import of some standard properties so I can maintain them outside of the WAP file but when I reference them in the element it doesn't like them. I suspect it's because the IISUrl element is part of which is a place to put non msbuild info.

您可以在下面的代码中看到,我试图在WebApp1.vbproj的几个位置引用$(CustomUrl),但是当我打开VS时却不喜欢它.

As you can see in the code below, I'm trying to reference $(CustomUrl) in a couple spots in the WebApp1.vbproj but when I open VS it's not liking it.

任何解决此问题的方法,或者任何人都有更好的方法来分支Web应用程序项目.

Any way to resolve this or does anyone have a better way to branch off Web Application projects.

CustomImport.vbproj

<Project 
    xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
        <CustomUrl>http://localhost/WebUrl_1</CustomUrl>
    </PropertyGroup>
</Project>

WebApp1.vbproj

<Import Project="CustomImport.vbproj"/>
<WebProjectProperties>
  <UseIIS>True</UseIIS>
  <AutoAssignPort>True</AutoAssignPort>
  <DevelopmentServerPort>1124</DevelopmentServerPort>
  <DevelopmentServerVPath>/</DevelopmentServerVPath>
  <IISUrl>$(CustomUrl)</IISUrl>
  <OverrideIISAppRootUrl>True</OverrideIISAppRootUrl>
  <IISAppRootUrl>$(CustomUrl)/</IISAppRootUrl>
  <NTLMAuthentication>False</NTLMAuthentication>
  <UseCustomServer>False</UseCustomServer>
  <CustomServerUrl>$(CustomUrl)</CustomServerUrl>
  <SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>

推荐答案

我相信我在VS2010中可能对此有解决方法.

I believe I might have a workaround for this in VS2010.

右键单击VS2010中的项目,然后转到属性".在"Web"选项卡中,取消选中将服务器设置应用于所有用户(存储在项目文件中)".这是强制将所有设置存储在[Web项目名称] .csproj.user文件中,而不是存储在项目文件本身中. (我的是C#项目,而不是VB,但我认为它的工作原理相同).这使您可以在进行开发的每台计算机上使用不同的服务器设置,但同时可以共享其余配置.

Right click on the project in VS2010 and go to Properties. In the Web tab, Uncheck the "Apply server settings to all users (store in project file)". What this does is forces all of the settings to be stored in a [Web Project Name].csproj.user file instead of in the project file itself. (Mine is a C# project instead of VB, but I assume it works the same) This allows you to have different server settings on each machine doing development, but at the same time share the rest of the configuration.

我之所以必须这样做,是因为我在每台开发机(工作站和笔记本电脑)上都使用SSL证书,因此项目URL是不同的,但是我不想在每台计算机上手动乱搞URL的次数超过了一次,并在将我的代码检入源代码管理时担心它.

I had to do this because I'm using SSL certificates on each development machine (workstation and laptop) so the Project URL is different, but I don't want to have to manually mess with the URL on each machine more than once and worry about it while checking my code into source control.

获取最新资源后,在计算机上完成初始配置后,您的.user文件将保存该配置.只要您不将.user文件签入源代码管理中,这似乎就可以正常工作.

Once you've done the initial configuration on a machine after getting the latest source, your .user file holds the configuration. So long as you're not checking .user files into source control this seems to work fine.

这篇关于动态设置Web应用程序项目的IISUrl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆