這個來自微軟的關于trubleshooting XAML Hot reload的頁面這樣說:
默認情況下,源資訊被包含在除錯配置中。它由您的專案檔案(如*.csproj)中的MSBuild屬性控制。對于WPF,該屬性是XamlDebuggingInformation,它必須被設定為True。對于UWP,該屬性是DisableXbfLineInfo,它必須被設定為False。例如:
WPF:
<XamlDebuggingInformation>True</XamlDebuggingInformation>/code>UWP:
<DisableXbfLineInfo>False</DisableXbfLineInfo>/code>
由于我的專案配置名稱不是 "Debug",所以熱多載屬性不會自動出現在我的MSBuild配置中,正如你所看到的,微軟建議我在我的.csProj中添加XamlDebuggingInformation,以便讓XAML熱多載作業,但我不知道如何做。
我試著在<PropertyGroup>標簽中添加一個新行,其中有我想要應用的配置,但之后Visual Studio很難加載。我應該如何添加這個MSBuild屬性呢?
csproj檔案的例子
<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=" '$(配置)' == '' "> Debug</Configuration>。
<Platform Condition=" '$(Platform)' == '' "/span>> AnyCPU</Platform>。
<ProjectGuid>{1EA7A7EC-D092-4DE3-B8DD-49F74B71ACF2}</ProjectGuid>/span>
<OutputType>WinExe</OutputType>
<RootNamespace>/span>PatchDeDup</RootNamespace>/span>
<AssemblyName>PatchDeDup</AssemblyName>
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>/span>
<FileAlignment>512</FileAlignment>/span>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-b4bc16c2548}。 {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>/span>
<Deterministic>true</Deterministic>
</PropertyGroup>/span>
<PropertyGroup Condition=" '$(配置)|$(平臺)' ==' Release|AnyCPU'" >
<PlatformTarget>/span>AnyCPU</PlatformTarget>/span>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>binRelease</OutputPath>
<DefineConstants>/span>TRACE</DefineConstants>/span>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>/span>
</PropertyGroup>/span>
<PropertyGroup Condition="'$(配置)|$(平臺)' =='OtherDebug|AnyCPU'"/span>>
<DebugSymbols>true</DebugSymbols>/span>
<OutputPath>/span>binOtherDebug</OutputPath>/span>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>/span>AnyCPU</PlatformTarget>/span>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>/span>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>。
... 檔案包括,依賴性參考等。(相當通用的wpf專案的東西)
我以為我必須在<XamlDebuggingInformation>True</XamlDebuggingInformation>內為OtherDebug|AnyCPU添加PropertyGroup,但VS 2019顯然不希望這樣...
uj5u.com熱心網友回復:
我的解決方案最后真的很簡單。打開.csProj檔案,找到PropertyGroup,它具有你所期望的配置名稱,并將<XamlDebuggingInformation>True</XamlDebuggingInformation>添加到XML標簽的主體。
對于我來說,我不得不在 Visual Studio 關閉時進行這項作業,因為解決方案重新加載失敗,Visual Studio 被卡在了一個無限的回圈中。但是在打開之前添加它就可以了:)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/312739.html
標籤:
