繁体   English   中英

调试 ASP.NET (.NET Framework 4.8) web 应用程序时,没有为新 csproj 格式的 (.NET Framework 4.8) 库加载符号

[英]No symbols loaded for a (.NET Framework 4.8) library in new csproj format when debugging a ASP.NET (.NET Framework 4.8) web application

我有一个 ASP.NET (.NET Framework 4.8) web 应用程序,我们多年来一直在开发和发展。

我花了一些时间将它使用的许多 Class 库转换为新的 csproj 格式,但 class 库仍然针对 .NET Framework 4.8 (net48)。

该应用程序编译并运行良好。 但是,我刚刚尝试调查一个问题,发现在调试时,不再为转换后的 class 库加载符号,我无法再单步执行这些 class 库中的代码。

转换后的 class 库的典型.csproj 如下:

<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <ProductVersion>9.0.30729</ProductVersion>
        <SchemaVersion>2.0</SchemaVersion>
        <OutputType>Library</OutputType>
        <AppDesignerFolder>Properties</AppDesignerFolder>
        <TargetFramework>net48</TargetFramework>
        <SccProjectName>SAK</SccProjectName>
        <SccLocalPath>SAK</SccLocalPath>
        <SccAuxPath>SAK</SccAuxPath>
        <SccProvider>SAK</SccProvider>
        <Optimize>true</Optimize>
        <LangVersion>8.0</LangVersion>
    </PropertyGroup>
    <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
        <DebugType>full</DebugType>
        <DebugSymbols>true</DebugSymbols>
    </PropertyGroup>
    <ItemGroup>
        <Reference Include="Microsoft.CSharp" />
        <Reference Include="System" />
        <Reference Include="System.ComponentModel.DataAnnotations" />
        <Reference Include="System.configuration" />
        <Reference Include="System.Core" />
        <Reference Include="System.Data" />
        <Reference Include="System.Drawing" />
        <Reference Include="System.Net.Http" />
        <Reference Include="System.Numerics" />
        <Reference Include="System.Runtime.Serialization" />
        <Reference Include="System.Security" />
        <Reference Include="System.Web" />
        <Reference Include="System.Xml" />
    </ItemGroup>
    <ItemGroup>
        <None Include="RSPlatform.Core.ruleset" />
        <None Include="Properties\DataSources\P42Entities.datasource" />
        <None Include=".editorconfig" />
        <None Include="App.Config">
            <SubType>Designer</SubType>
        </None>
        <EmbeddedResource Include="AssessmentPlus\TemplateInstall\Data\AssessmentSchema.xsd">
            <SubType>Designer</SubType>
        </EmbeddedResource>
    </ItemGroup>
    <ItemGroup>
        <EmbeddedResource Include="AssessmentPlus\TemplateInstall\Data\ImportInfo.xml" />
        <None Include="Properties\Settings.settings">
            <Generator>SettingsSingleFileGenerator</Generator>
            <LastGenOutput>Settings.Designer.cs</LastGenOutput>
        </None>
        <None Include="AssessmentPlus\TemplateInstall\Data\WA_Test_MiniAssessment.xml" />
        <None Include="AssessmentPlus\TemplateInstall\Data\WA_Test_NumberedAssessment.xml" />
        <EmbeddedResource Include="AssessmentPlus\TemplateInstall\Data\StandardAssessment.xml" />
    </ItemGroup>
    <ItemGroup>
        <EmbeddedResource Include="AssessmentPlus\TemplateInstall\Data\WA_AtosAssessment_v5.xml" />
    </ItemGroup>
    <ItemGroup>
        <ProjectReference Include="..\RSPlatform.Common\RSPlatform.Common.csproj" />
        <ProjectReference Include="..\RSPlatform.Crypt\RSPlatform.Crypt.csproj" />
        <ProjectReference Include="..\RSPlatform.Data.Core\RSPlatform.Data.Core.csproj" />
        <ProjectReference Include="..\RSPlatform.Mail\RSPlatform.Mail.csproj" />
    </ItemGroup>
    <ItemGroup>
        <EmbeddedResource Include="AssessmentPlus\TemplateInstall\Data\DA_Standard.xml">
            <SubType>Designer</SubType>
        </EmbeddedResource>
        <Content Include="AssessmentPlus\TemplateInstall\Data\Template-Text-Extract.xslt" />
        <EmbeddedResource Include="AssessmentPlus\TemplateInstall\Data\WA_Standard.xml" />
        <Content Include="AssessmentPlus\TemplateInstall\Data\Template-HTML-Extract.xslt" />
    </ItemGroup>
    <ItemGroup>
        <Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
    </ItemGroup>
    <ItemGroup>
        <PackageReference Include="EntityFramework" Version="6.4.0" />
        <PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" />
        <PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.0.0" />
        <PackageReference Include="Microsoft.CodeAnalysis.VersionCheckAnalyzer" Version="3.0.0" />
        <PackageReference Include="Microsoft.CodeQuality.Analyzers" Version="3.0.0" />
        <PackageReference Include="Microsoft.Extensions.Http" Version="3.1.3" />
        <PackageReference Include="Microsoft.NetCore.Analyzers" Version="3.0.0" />
        <PackageReference Include="Microsoft.NetFramework.Analyzers" Version="3.0.0" />
        <PackageReference Include="RealSense.DomainBasedConfig" Version="1.2.0" />

        <PackageReference Include="AutoMapper" Version="9.0.0" />
        <PackageReference Include="iTextSharp" Version="5.5.13.1" />
        <PackageReference Include="LinqKit" Version="1.1.17" />
        <PackageReference Include="Mehdime.Entity" Version="1.0.0" />
        <PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
        <PackageReference Include="Ninject" Version="3.3.4" />
    </ItemGroup>
</Project>

未更改的 ASP.NET web 应用程序仍然是旧格式,因为微软仍然没有引入对新 csproj 格式的支持(尽管几年前就已经讨论过了)。 它看起来像这样:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="..\..\..\..\..\..\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.3.0.0\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props" Condition="Exists('..\..\..\..\..\..\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.3.0.0\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props')" />
  <Import Project="..\..\..\..\..\..\packages\Microsoft.NetFramework.Analyzers.3.0.0\build\Microsoft.NetFramework.Analyzers.props" Condition="Exists('..\..\..\..\..\..\packages\Microsoft.NetFramework.Analyzers.3.0.0\build\Microsoft.NetFramework.Analyzers.props')" />
  <Import Project="..\..\..\..\..\..\packages\Microsoft.NetCore.Analyzers.3.0.0\build\Microsoft.NetCore.Analyzers.props" Condition="Exists('..\..\..\..\..\..\packages\Microsoft.NetCore.Analyzers.3.0.0\build\Microsoft.NetCore.Analyzers.props')" />
  <Import Project="..\..\..\..\..\..\packages\Microsoft.CodeQuality.Analyzers.3.0.0\build\Microsoft.CodeQuality.Analyzers.props" Condition="Exists('..\..\..\..\..\..\packages\Microsoft.CodeQuality.Analyzers.3.0.0\build\Microsoft.CodeQuality.Analyzers.props')" />
  <Import Project="..\..\..\..\..\..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.3.0.0\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props" Condition="Exists('..\..\..\..\..\..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.3.0.0\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props')" />
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <Import Project="C:\packages\EntityFramework.6.4.0\build\EntityFramework.props" Condition="Exists('C:\packages\EntityFramework.6.4.0\build\EntityFramework.props')" />
  <Import Project="C:\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('C:\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProductVersion>
    </ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{52F85C76-86BD-4924-BD61-8ECF32D9075A}</ProjectGuid>
    <ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>PlatformNET</RootNamespace>
    <AssemblyName>PlatformNET</AssemblyName>
    <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
    <SccProjectName>SAK</SccProjectName>
    <SccLocalPath>SAK</SccLocalPath>
    <SccAuxPath>SAK</SccAuxPath>
    <SccProvider>SAK</SccProvider>
    <UseIISExpress>true</UseIISExpress>
    <FileUpgradeFlags>
    </FileUpgradeFlags>
    <UpgradeBackupLocation>
    </UpgradeBackupLocation>
    <OldToolsVersion>4.0</OldToolsVersion>
    <IISExpressSSLPort>44328</IISExpressSSLPort>
    <IISExpressAnonymousAuthentication />
    <IISExpressWindowsAuthentication />
    <IISExpressUseClassicPipelineMode />
    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
    <TargetFrameworkProfile />
    <UseGlobalApplicationHostFile />
    <NuGetPackageImportStamp>
    </NuGetPackageImportStamp>
    <Use64BitIISExpress />
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\</OutputPath>
    <DefineConstants>TRACE;DEBUG</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <PublishDatabases>false</PublishDatabases>
    <Prefer32Bit>false</Prefer32Bit>
    <DocumentationFile>
    </DocumentationFile>
    <NoWarn>CA1303;CA1308;CA1028;CA1056;CA1707;CA1031;CA1710;CA1305</NoWarn>
    <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
    <LangVersion>default</LangVersion>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <FilesToIncludeForPublish>OnlyFilesToRunTheApp</FilesToIncludeForPublish>
    <PackageAsSingleFile>true</PackageAsSingleFile>
    <PrecompileBeforePublish>true</PrecompileBeforePublish>
    <UseMerge>true</UseMerge>
    <WDPMergeOption>MergeAllOutputsToASingleAssembly</WDPMergeOption>
    <EnableUpdateable>false</EnableUpdateable>
    <SingleAssemblyName>MyPrecompiled</SingleAssemblyName>
    <PublishDatabases>false</PublishDatabases>
    <ExcludeApp_Data>false</ExcludeApp_Data>
    <Prefer32Bit>false</Prefer32Bit>
    <DocumentationFile>
    </DocumentationFile>
    <NoWarn>CA1303;CA1308;CA1028;CA1056;CA1707;CA1031;CA1710;CA1305</NoWarn>
    <CodeAnalysisRuleSet>PlatformNET.ruleset</CodeAnalysisRuleSet>
    <LangVersion>default</LangVersion>
  </PropertyGroup>
 ...
  <UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Web\Microsoft.Web.Publishing.Tasks.dll" />
  <Target Name="AfterBuild" Condition="Exists('Web.$(Configuration).config')">
    <!--Generate transformed config in the output directory-->
    <TransformXml Source="Web.config" Destination="$(OutputPath)Web.config" Transform="Web.$(Configuration).config" />
  </Target>
  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
    <PropertyGroup>
      <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
    </PropertyGroup>
    <Error Condition="!Exists('C:\packages\EntityFramework.6.4.0\build\EntityFramework.props')" Text="$([System.String]::Format('$(ErrorText)', 'C:\packages\EntityFramework.6.4.0\build\EntityFramework.props'))" />
    <Error Condition="!Exists('C:\packages\EntityFramework.6.4.0\build\EntityFramework.targets')" Text="$([System.String]::Format('$(ErrorText)', 'C:\packages\EntityFramework.6.4.0\build\EntityFramework.targets'))" />
    <Error Condition="!Exists('C:\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', 'C:\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" />
    <Error Condition="!Exists('..\..\..\..\..\..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.3.0.0\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\..\..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.3.0.0\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props'))" />
    <Error Condition="!Exists('..\..\..\..\..\..\packages\Microsoft.CodeQuality.Analyzers.3.0.0\build\Microsoft.CodeQuality.Analyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\..\..\packages\Microsoft.CodeQuality.Analyzers.3.0.0\build\Microsoft.CodeQuality.Analyzers.props'))" />
    <Error Condition="!Exists('..\..\..\..\..\..\packages\Microsoft.NetCore.Analyzers.3.0.0\build\Microsoft.NetCore.Analyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\..\..\packages\Microsoft.NetCore.Analyzers.3.0.0\build\Microsoft.NetCore.Analyzers.props'))" />
    <Error Condition="!Exists('..\..\..\..\..\..\packages\Microsoft.NetFramework.Analyzers.3.0.0\build\Microsoft.NetFramework.Analyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\..\..\packages\Microsoft.NetFramework.Analyzers.3.0.0\build\Microsoft.NetFramework.Analyzers.props'))" />
    <Error Condition="!Exists('..\..\..\..\..\..\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.3.0.0\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\..\..\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.3.0.0\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props'))" />
  </Target>
  <Import Project="C:\packages\EntityFramework.6.4.0\build\EntityFramework.targets" Condition="Exists('C:\packages\EntityFramework.6.4.0\build\EntityFramework.targets')" />
</Project>   

有什么方法可以让 class 库在调试器中完全工作? 还是我将不得不有一点愤怒,然后“撤消”所有的转换工作?

EDIT: So on a separate machine I created a NEW ASP.NET Framework Web App and two class libraries (a .NET Framework 4.7.2 and a .NET Standard 2.1 one). 我能够进入两个 class 库,所以这似乎不是由于新的 csproj 格式本身。

回到我有问题的解决方案,我可以看到 .NET 标准 Class 库在bin文件夹中有一个 .PDF 文件,但调试器 Z148E6221F63983

跳过加载符号。 模块已优化并启用了调试器选项“仅我的代码”

Just My Code 已启用,但我认为“模块已优化”是真正的问题。 我正在编译为 DEBUG 而不是 RELEASE。 关于我需要在“.NET Standard Class Lib”.csproj 文件中更改哪些内容以编译 DEBUG 版本而不进行优化的任何想法?

谢谢克里斯

因此,如开头问题所述,Build Output 显示这些模块不加载符号,因为 output 已“优化”(GB 优化)。

Project Properties 页面的 Build Tab 包括两个复选框:“Define DEBUG constant”和“Optimize code”。 在查看调试配置时,第一个未被选中,第二个被选中。

反转这两个(调试配置)解决了提出的问题。 但是,“优化代码”似乎不是特定于配置的,在更改后查看底层 csproj 文件,我可以看到它是在配置之外定义的:

<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        ...
        <TargetFramework>net48</TargetFramework>
        <Optimize>false</Optimize>                  <-- Not Configuration specific
        <LangVersion>8.0</LangVersion>
    </PropertyGroup>
    <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
        <DebugType>full</DebugType>
        <DebugSymbols>true</DebugSymbols>
        <DefineConstants>DEBUG</DefineConstants>    <-- Configuration specific
    </PropertyGroup>

我发现我可以添加一个“Release|AnyCPU”配置/平台并在每个版本中移动<Optimize>值来解决这个问题:

<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <ProductVersion>9.0.30729</ProductVersion>
        <SchemaVersion>2.0</SchemaVersion>
        <OutputType>Library</OutputType>
        <AppDesignerFolder>Properties</AppDesignerFolder>
        <TargetFramework>net48</TargetFramework>
        <SccProjectName>SAK</SccProjectName>
        <SccLocalPath>SAK</SccLocalPath>
        <SccAuxPath>SAK</SccAuxPath>
        <SccProvider>SAK</SccProvider>        <-- Removed <Optimize> from here
        <LangVersion>8.0</LangVersion>
    </PropertyGroup>
    <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">    <-- ADDED
        <DebugType>full</DebugType>
        <DebugSymbols>true</DebugSymbols>
        <Optimize>true</Optimize>             <-- ADDED
    </PropertyGroup>
    <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
        <DebugType>full</DebugType>
        <DebugSymbols>true</DebugSymbols>
        <DefineConstants>DEBUG</DefineConstants>
        <Optimize>false</Optimize>            <-- ADDED
    </PropertyGroup>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM