Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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>
  <DevelopmentServerVPath>/</DevelopmentServerVPath>
  <IISUrl>$(CustomUrl)</IISUrl>
  <OverrideIISAppRootUrl>True</OverrideIISAppRootUrl>
  <IISAppRootUrl>$(CustomUrl)/</IISAppRootUrl>
  <NTLMAuthentication>False</NTLMAuthentication>
  <UseCustomServer>False</UseCustomServer>
  <CustomServerUrl>$(CustomUrl)</CustomServerUrl>
  <SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
like image 447
Richard Edwards Avatar asked Mar 04 '10 11:03

Richard Edwards


1 Answers

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.

like image 171
Mike Taber Avatar answered Sep 16 '22 11:09

Mike Taber