开发者

Dynamically setting the IISUrl of a Web Application Project

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.

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.

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>
  &l开发者_如何学运维t;DevelopmentServerVPath>/</DevelopmentServerVPath>
  <IISUrl>$(CustomUrl)</IISUrl>
  <OverrideIISAppRootUrl>True</OverrideIISAppRootUrl>
  <IISAppRootUrl>$(CustomUrl)/</IISAppRootUrl>
  <NTLMAuthentication>False</NTLMAuthentication>
  <UseCustomServer>False</UseCustomServer>
  <CustomServerUrl>$(CustomUrl)</CustomServerUrl>
  <SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>


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

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.

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.

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.


I've been plagued by the same problem for several years now. The problem persists all the way from Visual Studio .NET (2003) up until now (VS 2010). I have searched for an automated solution for automatic URL renaming but without any success.

What I've been doing to avoid this problem is branching way more and having lots of different workspaces:

Root branch for ongoing project -> Branch for dev-team -> Branch for support and long-term code integrity (this is the most commonly used branch by me) -> My personal custom branches that have different URLs set

I know it's not the best solution but this is the best one that I could figure out.


This article on programmatically changing a project file may be of some use to you in creating a solution to automate the changing of those settings: Programmatically change Web project settings from dynamic port to static

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜