Is it able to check XAML Designer mode in csproj?

William Liu 556 Reputation points
2024-07-29T05:22:41.65+00:00

I have a .net 8 WPF project which is developed with lastest Visual Studio Community Version (v17.10.5).

I have learned that I can use Condition attribute in csproj file to toggle build property.

My question is, is there a Condition key word to check if current environment is in the Visual Studio XAML Designer mode, not a actual WPF running environment? I would like to introduce some design resource library which only used for helping XAML designer work, but I don't want to include this library in the actual project.

Expected:

  <ItemGroup>
    <ProjectReference Condition=" '$(XamlDesignerMode)' == 'true' "
                      Include="..\DesignerResource\DesignerResource.csproj" />
  </ItemGroup>
Developer technologies | Windows Presentation Foundation
Developer technologies | Visual Studio | Other
{count} votes

Accepted answer
  1. Hui Liu-MSFT 48,681 Reputation points Microsoft External Staff
    2024-07-30T08:51:58.16+00:00

    Hi,@William Liu. Base on my research, you could check if the private asset concept matches your needs, learn.microsoft.com/nuget/consume-packages/… but that condition doesn't exist.

    Another possible approach is to test and see if the DesignTimeBuild property will work for your need.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.