如何将XamlDebuggingInformation MSBuild属性添加到CsProj? [英] How do I add XamlDebuggingInformation MSBuild property to CsProj?

查看:28
本文介绍了如何将XamlDebuggingInformation MSBuild属性添加到CsProj?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

This page来自Microsoft的关于XAML热重新加载的Trubleshooting说明:

默认情况下,源信息包含在调试配置中。它由项目文件(如*.csproj)中的MSBuild属性控制。对于WPF,该属性为XamlDebuggingInformation,必须设置为True。对于UWP,该属性为DisableXbfLineInfo,必须设置为False。例如:

WPF:<XamlDebuggingInformation>True</XamlDebuggingInformation>

UWP:<DisableXbfLineInfo>False</DisableXbfLineInfo>

由于我的项目配置名称不是&q;Debug&q;,因此热重新加载属性不会自动出现在我的MSBuild配置中,而且正如您所见,Microsoft建议我将XamlDebuggingInformation添加到我的.csProj中以使XAML热加载正常工作,但我不知道如何执行此操作。

我尝试只在<PropertyGroup>标记中添加一行新行,该标记具有我想要应用的配置,但之后Visual Studio加载起来非常困难。如何添加此MSBuild属性?

csproj文件示例

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="16.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)$(MSBuildToolsVersion)Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)$(MSBuildToolsVersion)Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{1EA7A7EC-D092-4DE3-B8DD-49F74B71ACF2}</ProjectGuid>
    <OutputType>WinExe</OutputType>
    <RootNamespace>PatchDeDup</RootNamespace>
    <AssemblyName>PatchDeDup</AssemblyName>
    <TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
    <WarningLevel>4</WarningLevel>
    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
    <Deterministic>true</Deterministic>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>binRelease</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'OtherDebug|AnyCPU'">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>binOtherDebug</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <DebugType>full</DebugType>
    <PlatformTarget>AnyCPU</PlatformTarget>
    <ErrorReport>prompt</ErrorReport>
    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
    <Prefer32Bit>true</Prefer32Bit>
  </PropertyGroup>
  ... file includes, dependency references, etc. (pretty generic wpf project stuff)

我假设我必须在PropertyGroup中为OtherDebug|AnyCPU添加<XamlDebuggingInformation>True</XamlDebuggingInformation>,但VS 2019预计这显然不会.

推荐答案

我的解决方案最终变得非常简单。打开.csProj文件,找到具有预期配置名称的PropertyGroup,并将<XamlDebuggingInformation>True</XamlDebuggingInformation>添加到XML标记的正文中。

对我来说,我不得不在Visual Studio关闭时执行此操作,因为解决方案重新加载失败,并且Visual Studio陷入无限循环。但在开张前添加是可以的:)

这篇关于如何将XamlDebuggingInformation MSBuild属性添加到CsProj?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆