Add support for using a 3.0 SDK on VS 16.4.

- The 3.0 SDK adds RazorDeclaration files to the compile list if they exist. If a user builds in VS and then does a project level operation (adding a property group or item group to their project file) a design time build will trigger for unrelated reasons and declaration files will be included as part of the C# compilation resulting in duplicate member errors. This change ensures that even if declaration files are added we then remove them to ensure we avoid those declaration additions.
- One unfortunate aspect of this change is that declarations are added to the compile list for a brief moment resulting in errors and then are instantly removed in some situations. I say "some situations" because when this happens it is highly dependent on how / when the project system decides to perform a design time build.

aspnet/AspNetCoredotnet/aspnetcore-tooling#14646
\n\nCommit migrated from b64c9317c4
This commit is contained in:
N. Taylor Mullen 2019-10-10 09:43:59 -07:00
parent abef940002
commit 49f8ae28cf
1 changed files with 11 additions and 0 deletions

View File

@ -47,6 +47,17 @@ Copyright (c) .NET Foundation. All rights reserved.
<ProjectCapability Include="SupportsTypeScriptNuGet" />
</ItemGroup>
<!--
In order to properly support Blazor partial classes we need to ensure that older SDKs don't
add declaration files to the compile list. We do all the compilation work in-memory in latest
VS.
-->
<Target Name="_RemoveRazorDeclartionsFromCompile" AfterTargets="RazorGenerateComponentDeclaration">
<ItemGroup Condition="'$(DesignTimeBuild)'=='true'">
<Compile Remove="@(_RazorComponentDeclaration)" />
</ItemGroup>
</Target>
<!--
WebSdk imports these capabilities for nesting in DotNetCoreWeb projects.
Conditinally import these capabilities if the project isn't targeting the WebSdk.