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

Code files in App_Code should be marked as content #4

Closed TheJayMann closed 3 years ago

TheJayMann commented 3 years ago

According to https://github.com/dotnet/project-system/issues/2670#issuecomment-820649507, code files found in App_Code need to be specified as Content instead of the default Compile used for code files. I believe the following ItemGroup would work.

<ItemGroup>
  <Compile Remove="App_Code\*.cs" />
  <Compile Remove="App_Code\*.vb" />
  <Content Include="App_Code\*.cs" />
  <Content Include="App_Code\*.vb" />
</ItemGroup>
bachratyg commented 3 years ago

This should probably be a little more appropriate

<ItemGroup>
  <Compile Remove="App_Code\*$(DefaultLanguageSourceExtension)" />
  <Content Include="App_Code\*$(DefaultLanguageSourceExtension)" />
</ItemGroup>

Maybe even add this:

Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)"
CZEMacLeod commented 3 years ago

@bachratyg Pull Requests welcome ;) I have tried to use DefaultLanguageSourceExtension in the past, but I've not always found it works, perhaps due to when it gets set.

I don't really use website projects, just web application projects (if my memory of the naming is correct) myself. This means that the App_* folders etc. are not something I use or really test with. In fact, I have been using RazorGenerator for a lot of years now, so I use this only for my 'head' projects.

That said, I have been using my own version of this for some time, and have migrated my custom implementations to use this package and not had any issues.