首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在调试.NET (.NET Framework4.8) web应用程序时,没有以新的csproj格式加载(.NET Framework4.8)库的符号

在调试.NET (.NET Framework4.8) web应用程序时,没有以新的csproj格式加载(.NET Framework4.8)库的符号
EN

Stack Overflow用户
提问于 2020-05-21 18:23:04
回答 1查看 490关注 0票数 0

我有一个ASP.NET (.NET Framework4.8) web应用程序,我们已经开发和开发了很多年。

我花了一些时间将它使用的许多类库转换成新的csproj格式,但是类库仍然针对.NET Framework4.8 (net48)。

应用程序编译并运行良好。然而,我刚刚尝试研究一个问题,发现在调试时,符号不再加载到转换的类库中,并且我不能再在这些类库中遍历代码。

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

代码语言:javascript
复制
<?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格式的支持(尽管几年前就有这样的说法)。看起来是这样的:

代码语言:javascript
复制
<?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>   

有什么方法可以让类库在调试器中完全工作吗?或者,我会有一点愤怒,然后“撤销”所有的转换工作?

编辑:因此,在一台单独的机器上,我创建了一个新的ASP.NET框架Web和两个类库( .NET Framework4.7.2和.NET标准2.1One)。我能够进入两个类库,所以这似乎不是因为新的csproj格式本身。

回到我的问题解决方案,我可以看到teh .NET标准类库在bin文件夹中有一个.PDF文件,但是Debugger输出显示:

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

只是我的代码是启用的,但是我认为“模块优化”才是真正的问题。我正在编译为调试而不是发布。知道我需要在".NET标准类Lib“.csproj文件中修改什么来编译没有优化的调试版本吗?

谢谢克里斯

EN

回答 1

Stack Overflow用户

发布于 2020-05-22 10:11:21

因此,正如在开头问题中所述,构建输出表明这些模块不加载符号,因为输出是“优化的”(GB优化)。

项目属性页面的构建选项卡包括两个复选框:“定义调试常量”和“优化代码”。第一个是未检查的,第二个是在查看调试配置时检查的。

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

代码语言:javascript
复制
<?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”配置/平台,并在每个版本中移动<Optimize>值,修复如下:

代码语言:javascript
复制
<?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>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61941232

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档