Question

I'm building project templates in Visual Studio 2012. One of these is generated from an empty MVC4 project. What I need to change (except some file includes, which already works) is the web server settings, available under Project settings > Web > Servers.

I need to set it to "Use Custom Web Server". I put this is the template csproj:

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

However, when the project is created - it seems to be overwritten to the "normal" defaults, with IIS Express on autogenerated port. Is there something required to change this in addition?

Was it helpful?

Solution

The "solution" I finally went with does not actually resolve the fact that the section seems to be overwritten, but rather puts a bit of duct tape on it...

I implemented a wizard which I added to the template. In the implementation, I put code in the RunFinished method which opens the project file as a xml document, and simply replaces the section with what I want it to be. It sort of works, the only real drawback is that it will alert you that the project has been changed and needs to be reloaded as soon as it is added.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top