Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,21 @@
</ItemGroup>

<ItemGroup>
<!-- Need to make sure ObjectPool is in the bin folder for local development scenarios -->
<None Include="$(PkgMicrosoft_Extensions_ObjectPool)\lib\net8.0\Microsoft.Extensions.ObjectPool.dll" CopyToOutputDirectory="PreserveNewest" Visible="false" />
<!-- Need to make sure ObjectPool is in the bin folder for local development scenarios -->
<None Include="$(PkgMicrosoft_Extensions_ObjectPool)\lib\net8.0\Microsoft.Extensions.ObjectPool.dll" CopyToOutputDirectory="PreserveNewest" Visible="false" />

<Content Include="..\rzls\Targets\**\*.*">
<LinkBase>Targets</LinkBase>
<Pack>true</Pack>
<PackagePath>content\Targets</PackagePath>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>

<Content Include=".\Targets\**\*.targets">
<Pack>true</Pack>
<PackagePath>content\Targets</PackagePath>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

<Target Name="PackPublishContent" DependsOnTargets="Publish">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<!--
***********************************************************************************************
Microsoft.CSharpExtension.DesignTime.targets

A polyfill for the real Microsoft.CSharp.DesignTime.targets file that is supplied by the .NET
project system in Visual Studio and the C# Dev Kit extension.
https://github.com/dotnet/project-system/blob/8ba13c7fa917b86462e0ff32a07ef3e15eb8dfa6/src/Microsoft.VisualStudio.ProjectSystem.Managed/ProjectSystem/DesignTimeTargets/Microsoft.CSharp.DesignTime.targets

WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
created a backup copy. Incorrect changes to this file will make it
impossible to load or build your projects from the command-line or the IDE.
Comment on lines +9 to +11
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But who can edit this file if only those knowledgable in MSBuild can edit it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats why I created the file, because I'm not qualified to modify it 😁


Copyright (c) .NET Foundation. All rights reserved.
***********************************************************************************************
-->

<Project>

<!-- Razor cohosting support for projects that don't use the Razor SDK -->

<!--
If there are any .razor or .cshtml files in this project we want to do three things:

1. Add a 'RazorWithoutSdk' capability to the project so tooling can light up as necessary
2. Reference the Razor source generator
3. Add each .razor and .cshtml file to the project as an AdditionalFiles item so the source generator can see it
-->

<!-- .NET Framework uses a different editor in VS -->
<Target Name="DetectRazorOrCshtmlFiles" BeforeTargets="AssignProjectConfiguration" Condition="'$(UsingMicrosoftNETSdkRazor)' != 'true'">
<ItemGroup>
<!-- Collect all Razor and CSHTML files -->
<_RazorOrCshtmlFiles Include="**\*.razor;**\*.cshtml" />
</ItemGroup>

<!-- Add a capability to control initialization of Razor in the IDE -->
<ItemGroup Condition="'@(_RazorOrCshtmlFiles)' != ''">
<ProjectCapability Include="RazorWithoutSdk" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to condition this with a 'back out' flag? I assume it won't do anything bad to have it on, so probably not?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, project capabilities don't do anything, they're just like attributes you attach to things. In this case, given this file is only used in the C# Extension, even adding the capability is redundant, since it doesn't do anything and nothing cares whether its there, but its easier to have the files matching :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but its easier to have the files matching :)

Is there a way to avoid the copy/paste of the file? Or if not, can this at least link to the other file somewhere so somebody knows when to update one they can also update the other?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is linked at the top of this file (at least, I think I remember doing that, but I'm typing this on my phone so who knows!)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You linked to the whole file, but that's a somewhat different flavor. Not sure if that repo should minimally extract a file out so some file can be the same, or whether we should just adopt that file into the C# extension project system directly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logged #12137

</ItemGroup>

<!-- As a get out of jail card, we let users turn off anything impactful, but their IDE won't really work. -->
<ItemGroup Condition="'$(DisableAllRazorFilesAsAdditionalFiles)' != 'true' And '@(_RazorOrCshtmlFiles)' != ''">
<AdditionalFiles Include="@(_RazorOrCshtmlFiles)" />
</ItemGroup>

<ItemGroup Condition="'$(DisableAutomaticRazorSourceGeneratorReference)' != 'true' And '@(_RazorOrCshtmlFiles)' != ''">
<!-- Our analyzer loader will redirect DLL loads to the right place for tooling, as long as the right filename is referenced -->
<Analyzer Include="Microsoft.CodeAnalysis.Razor.Compiler.dll" />
</ItemGroup>
</Target>

</Project>