MVC precompile publish

kristoffer's Avatar

kristoffer

21 Aug, 2014 04:34 PM

What is the recommended way in AppVeyor for web deploy with precompilation of a MVC project?

  1. Support Staff 1 Posted by Feodor Fitsner on 21 Aug, 2014 08:00 PM

    Feodor Fitsner's Avatar

    Hi Kristoffer,

    It's not yet support out of the box. Do you have any recommendations about how it could look in AppVeyor though?

  2. 2 Posted by kristoffer on 21 Aug, 2014 08:25 PM

    kristoffer's Avatar

    Ok, then I know that it's not supported. I will see what I come up with and let you guys know if I find a nice/clean way of doing it.

  3. 3 Posted by kristoffer on 21 Aug, 2014 09:57 PM

    kristoffer's Avatar
    <?xml version="1.0" encoding="utf-8"?>
    <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <PropertyGroup>
        <ExcludeApp_Data>True</ExcludeApp_Data>
        <DeleteExistingFiles>True</DeleteExistingFiles>
        <PrecompileBeforePublish>True</PrecompileBeforePublish>
        <EnableUpdateable>False</EnableUpdateable>
        <DebugSymbols>False</DebugSymbols>
        <WDPMergeOption>DonotMerge</WDPMergeOption>
      </PropertyGroup>
    </Project>
    

    This seems to generate the correct obj\Release\Package<projectname>.zip file when placed in projectname.wpp.targets file next to the webproject.csproj

    Parts of it is from the publishprofile I usually use.

    It does indeed package the app correctly and precompiles it (verified through unzip and checking views with false and true for PrecompileBeforePublish) also noticed that it compiles the App_Code folder (razor helpers) when run with PrecompileBeforePublish in the wpp.targets file

    Ran it with :

    > "C:\Program Files (x86)\MSBuild\12.0\bin\msbuild.exe" "projectname.csproj" /property:Configuration=Release /p:DeployOnBuild=True
    

    I will give this configuration a try tomorrow through an appVeyor build.

  4. Support Staff 4 Posted by Feodor Fitsner on 21 Aug, 2014 10:09 PM

    Feodor Fitsner's Avatar

    Wow, thanks for the great howto!

  5. 5 Posted by kristoffer on 21 Aug, 2014 10:18 PM

    kristoffer's Avatar

    Thank you Feodor,

    Just ran an AppVeyor build (Couldn't wait until tomorrow ;) ) and sure enough the web deploy artifact is precompiled.
    The only thing needed was that the file is present and the default MSBUILD command that appveyor runs takes care of the rest.

    Noticed one thing though! if you have

    <MvcBuildViews>true</MvcBuildViews>
    

    in the csproj for the configuration used for deploy then it can fail because that will result in two aspnetcompiler calls and the second one will fail.
    But that is no problem leaving it at false for RELEASE configuration or removing it since it will be compiled either way with the precompile

    More info about wpp.targets and what it is

    When you want to configure settings that apply to all profiles you use in a project, you create a .wpp.targets file. The .wpp.targets file must be located in the project folder and must be named projectname.wpp.targets.
    http://msdn.microsoft.com/en-us/library/ff398069(v=vs.110).aspx

  6. 6 Posted by kristoffer on 22 Aug, 2014 02:30 PM

    kristoffer's Avatar

    Noticed that the projectname.wpp.targets can override the MvcBuildViews so if we add it there we don't need to change the csproj if we have it enabled there to find errors in the views during development.

    <?xml version="1.0" encoding="utf-8"?>
    <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <PropertyGroup>
        <IncludeSetACLProviderOnDestination>False</IncludeSetACLProviderOnDestination>
        <ExcludeApp_Data>True</ExcludeApp_Data>
        <DeleteExistingFiles>True</DeleteExistingFiles>
        <PrecompileBeforePublish>True</PrecompileBeforePublish>
        <EnableUpdateable>False</EnableUpdateable>
        <DebugSymbols>False</DebugSymbols>
        <WDPMergeOption>DonotMerge</WDPMergeOption>
        <MvcBuildViews>False</MvcBuildViews>
      </PropertyGroup>
    </Project>
    
  7. kristoffer closed this discussion on 25 Aug, 2014 03:30 PM.

  8. Ilya Finkelshteyn re-opened this discussion on 04 Jul, 2017 07:13 PM

  9. 7 Posted by Ilya Finkelshte... on 04 Jul, 2017 07:13 PM

    Ilya Finkelshteyn's Avatar

    Addition note from another customer:

    The only thing I've done differently is to use a Condition attribute on the PropertyGroup element in the wpp.targets file so that we can do things differently for our dev build and staging build etc.

    e.g. Condition="'$(Configuration)|$(Platform)' == 'Production|AnyCPU'

  10. 8 Posted by Øyvind Valland on 05 Jul, 2017 07:48 AM

    Øyvind Valland's Avatar

    For completeness, this is what my wpp.targets file looks like with conditional PropertyGroups

    <?xml version="1.0"?>
    <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
        <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
            <ExcludeApp_Data>True</ExcludeApp_Data>
            <DeleteExistingFiles>True</DeleteExistingFiles>
            <PrecompileBeforePublish>False</PrecompileBeforePublish>
            <EnableUpdateable>False</EnableUpdateable>
            <DebugSymbols>False</DebugSymbols>
            <WDPMergeOption>DonotMerge</WDPMergeOption>
            <MvcBuildViews>False</MvcBuildViews>
        </PropertyGroup>
        <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Development|AnyCPU'">
            <ExcludeApp_Data>True</ExcludeApp_Data>
            <DeleteExistingFiles>True</DeleteExistingFiles>
            <PrecompileBeforePublish>True</PrecompileBeforePublish>
            <EnableUpdateable>False</EnableUpdateable>
            <DebugSymbols>False</DebugSymbols>
            <WDPMergeOption>DonotMerge</WDPMergeOption>
            <UseMerge>True</UseMerge>
            <SingleAssemblyName>CompiledViews</SingleAssemblyName>
            <MvcBuildViews>False</MvcBuildViews>
        </PropertyGroup>
        <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Production|AnyCPU'">
          <ExcludeApp_Data>True</ExcludeApp_Data>
          <DeleteExistingFiles>True</DeleteExistingFiles>
          <PrecompileBeforePublish>True</PrecompileBeforePublish>
          <EnableUpdateable>False</EnableUpdateable>
          <DebugSymbols>False</DebugSymbols>
          <WDPMergeOption>DonotMerge</WDPMergeOption>
            <UseMerge>True</UseMerge>
        <SingleAssemblyName>CompiledViews</SingleAssemblyName>
        <MvcBuildViews>False</MvcBuildViews>
      </PropertyGroup>
    </Project>
    
  11. Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 02:18 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

 

01 Oct, 2024 04:27 PM
26 Sep, 2024 03:49 PM
26 Sep, 2024 09:02 AM
25 Sep, 2024 07:07 PM
24 Sep, 2024 08:39 PM
24 Sep, 2024 06:47 AM