fix(build): Fixes building with VS 2019 16.10+ (#661)

**Note for Rider users** Code generation only works with Rider v2021.1+. For Rider 2021.1.x you must set a global msbuild attribute so that the IDE can recognize generated code after building. JetBrains claims this will be fixed in Rider 2021.2.

**Rider 2021.1 Required Setting for Code Generation**
<img width="945" alt="Screen Shot 2021-07-19 at 9 36 30 PM" src="https://user-images.githubusercontent.com/3953314/126262725-a4d58dd0-e9e0-400f-a172-0b29ef7a00d7.png">

**Note for VS 2019+ users**: Code generation requires completely cleaning your solution, doing a full build, closing VS 2019, and then opening the solution. This is a known issue and there are no plans to fix this multiple restart requirement for VS 2022 at this time.
This commit is contained in:
Kamron Batman 2021-07-19 21:43:29 -07:00 committed by GitHub
parent 679e8100f4
commit bd34e2fb0d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 18 deletions

View file

@ -10,8 +10,6 @@
<PublishDir>..\..\Distribution</PublishDir>
<OutDir>..\..\Distribution</OutDir>
<Version>0.0.0</Version>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>Generated</CompilerGeneratedFilesOutputPath>
</PropertyGroup>
<Target Name="CleanPub" AfterTargets="Clean">
<Message Text="Deleting source generated files..." />
@ -57,17 +55,21 @@
<PrivateAssets>all</PrivateAssets>
</ProjectReference>
</ItemGroup>
<Target Name="RemoveSourceGeneratedFiles" BeforeTargets="CoreCompile">
<ItemGroup>
<AdditionalFiles Include="Migrations/*.v*.json" />
</ItemGroup>
<PropertyGroup Condition="'$(RiderVersion)' != '' AND $([MSBuild]::VersionLessThan($(RiderVersion), '2021.2.0'))">
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>Generated</CompilerGeneratedFilesOutputPath>
</PropertyGroup>
<Target Name="RemoveSourceGeneratedFiles" BeforeTargets="CoreCompile" Condition="'$(RiderVersion)' != '' AND $([MSBuild]::VersionLessThan($(RiderVersion), '2021.2.0'))">
<ItemGroup>
<Compile Remove="Generated\**" />
</ItemGroup>
</Target>
<Target Name="AddSourceGeneratedFiles" AfterTargets="CoreCompile">
<Target Name="AddSourceGeneratedFiles" AfterTargets="CoreCompile" Condition="'$(RiderVersion)' != '' AND $([MSBuild]::VersionLessThan($(RiderVersion), '2021.2.0'))">
<ItemGroup>
<Compile Include="Generated\**" />
</ItemGroup>
</Target>
<ItemGroup>
<AdditionalFiles Include="Migrations/*.v*.json" />
</ItemGroup>
</Project>