How to generate code from shell script using MSBuild

I have a PowerShell script that generates a partial class based on the resource file that I have in my cs project.

I would like to include this new file at compile time.

Is Exec Task a Way? And if so, what are some examples of how to do this?

+3
source share
1 answer

This can be done by modifying the .csproj file to automatically include files of a specific template, for example.

<ItemGroup>
  <Compile Include="GeneratedPartialClasses\*.cs" />
</ItemGroup>

Please note that Visual Studio will also download these files as part of your project, so you may need to be careful that these generated files are not accidentally checked for source control.

0

All Articles