Publishing web application projects from Visual Studio

If you wish to use the Visual Studio Publish function (MSDeploy), we recommend installing Kentico projects with the web site configuration. Web application projects require additional manual steps before and during the publishing.

Before you use the Publish function of Visual Studio for Kentico web application projects, perform the following steps:

  1. Edit CMSApp.csproj either in a text editor or in Visual Studio:

    1. Right-click the CMSApp project and select Unload Project.
    2. Right-click the unloaded project again and select Edit CMSApp.csproj.
  2. Add the following code as the last child of the Project element (directly above </Project>):

    
    
    
     <PropertyGroup>
       <PipelineCollectFilesPhaseDependsOn>
         CustomBinaries;
         $(PipelineCollectFilesPhaseDependsOn);
       </PipelineCollectFilesPhaseDependsOn>
     </PropertyGroup>
     <Target Name="CustomBinaries">
       <Message Text="Collecting all contents of the bin folder." Importance="high"/>
       <ItemGroup>
         <_Binaries Include="bin\*.*" />
         <FilesForPackagingFromProject  Include="%(_Binaries.Identity)">
           <DestinationRelativePath>%(Identity)</DestinationRelativePath>
         </FilesForPackagingFromProject>
       </ItemGroup>
     </Target>
    
    
     
  3. Save the file. Reload the CMSApp project in Visual Studio (right-click and select Reload Project).

The project file change ensures that all binaries are present in the target location when you Publish web applications.

The Kentico solution consists of multiple web application projects (CMSApp, CMSApp_AppCode, CMSApp_MVC). You need to publish all of the projects to the same target location to ensure that the solution works correctly.

Note

After deploying the first project, make sure that your publish profile has the Delete all existing files prior to publish / Remove additional files at destination option disabled. You can configure the option in the Publish Web dialog in Settings -> File Publish Options.