Search code examples
c#msdeploy

MsDeploy: 2 webapplications in one solution


Here is my current setup: I have 1 solution (sln file) which holds 2 c# web applications inside one folder. When I publish solution with parameter SkipExtraFilesOnServer=True - it is delivered correctly. But, such an approach is not as good as it seems - it leaves deleted from solution files on server, and, in worst case (refactoring with assemblies renaming) can leave application after deployment in unusable state.

So, I would like to deliver with SkipExtraFilesOnServer=False, leaving cleanup and actual deployment to MsDeploy. But, in such scenario, second webapplication cleans up everything, which is not added to it. Is it possible to override SkipExtraFilesOnServer=False on subsequent builds webapplications, if it is SkipExtraFilesOnServer=False on first one?


Solution

  • I found solution for such an unlikely happen problem. In each of additional webapplication, one shall add at the end of csproj/vbproj file following:

      <Target Name="BeforeBuild">
    <PropertyGroup>
        <SkipExtraFilesOnServer Condition="!$(SkipExtraFilesOnServer)">True</SkipExtraFilesOnServer>
    </PropertyGroup>
    

    Or, if target BeforeBuild is already defined, add to it:

    <PropertyGroup>
        <SkipExtraFilesOnServer Condition="!$(SkipExtraFilesOnServer)">True</SkipExtraFilesOnServer>
    </PropertyGroup>