CZEMacLeod / MSBuild.SDK.SystemWeb

This MSBuild SDK is designed to allow for the easy creation and use of SDK (shortform) projects targeting ASP.NET 4.x using System.Web.
MIT License
151 stars 8 forks source link

*.aspx not ignored for compilation in Release-Build #22

Closed micmerchant closed 2 years ago

micmerchant commented 2 years ago

Hello,

we are currently migrating our ASP.NET Web Application from the old csproj format to the new SDK-Style Project format, but we are facing an issue with Release-Builds. It seems that .aspx files can't be ignored for compilation by the DefaultItemExcludes/ItemGroup directives. .cs files for example are properly ignored.

The interessting thing is, that this happens only in Release-Builds. Debug-Builds aren't affacted.

I've attached a simple example solution.

Thanks in advance, BR Michael WebApplication2.zip

CZEMacLeod commented 2 years ago

Hi - I'm guessing this is caused because the AspNetCompiler task is invoked when in release mode. I don't believe there is any way to pass explicit file paths to include or exclude to this task unfortunately (I think it mainly just wraps the Aspnet_compiler.exe.

The easy way to avoid this is to set the MvcBuildViews property to false in your project file and it won't then invoke this task/target during release builds.

<PropertyGroup>
   <MvcBuildViews>false</MvcBuildViews>
</PropertyGroup>

I think this is probably the same behaviour you would get in the original Web Application templates if MVC is selected. The templates in this project don't have quite the same nuances of being able to specify WebForms, MVC, and/or WebAPI so pretty much try to cover everything in one go.

micmerchant commented 2 years ago

Thank you, that solves our problem.