如何将 XamlDebuggingInformation MSBuild 属性 添加到 CsProj?
How do I add XamlDebuggingInformation MSBuild property to CsProj?
This page 来自 Microsoft 关于故障排除 XAML 热重载是这样说的:
By default, source info is included in a Debug configuration. It is controlled by MSBuild properties in your project files (such as *.csproj). For WPF, the property is XamlDebuggingInformation, which must be set to True. For UWP, the property is DisableXbfLineInfo, which must be set to False. For example:
WPF: <XamlDebuggingInformation>True</XamlDebuggingInformation>
UWP: <DisableXbfLineInfo>False</DisableXbfLineInfo>
由于我的项目配置名称不是“Debug”,热重载 属性 不会自动出现在我的 MSBuild 配置中,正如您所见,Microsoft 建议我将 XamlDebuggingInformation
添加到我的 .csProj为了让 XAML hotreloading 工作,但我不知道该怎么做。
我尝试在 <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>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'OtherDebug|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\OtherDebug\</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 陷入无限循环。但是在打开之前添加它很好:)
This page 来自 Microsoft 关于故障排除 XAML 热重载是这样说的:
By default, source info is included in a Debug configuration. It is controlled by MSBuild properties in your project files (such as *.csproj). For WPF, the property is XamlDebuggingInformation, which must be set to True. For UWP, the property is DisableXbfLineInfo, which must be set to False. For example:
WPF:
<XamlDebuggingInformation>True</XamlDebuggingInformation>
UWP:
<DisableXbfLineInfo>False</DisableXbfLineInfo>
由于我的项目配置名称不是“Debug”,热重载 属性 不会自动出现在我的 MSBuild 配置中,正如您所见,Microsoft 建议我将 XamlDebuggingInformation
添加到我的 .csProj为了让 XAML hotreloading 工作,但我不知道该怎么做。
我尝试在 <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>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'OtherDebug|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\OtherDebug\</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 陷入无限循环。但是在打开之前添加它很好:)