Is it able to check XAML Designer mode in csproj?

William Liu 466 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>
Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,784 questions
Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,193 questions
{count} votes

Accepted answer
  1. Hui Liu-MSFT 48,571 Reputation points Microsoft Vendor
    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.