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

问题描述 投票:0回答:1

我有一个已经开发并发展了多年的ASP.NET(.NET Framework 4.8)Web应用程序。

我花了一些时间将它使用的许多类库转换为新的csproj格式,但类库仍以.NET Framework 4.8(net48)为目标。

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

转换后的类库的典型.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应用程序仍然是旧格式,因为Microsoft仍未提供对新的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>   

有什么方法可以使类库在调试器中完全起作用?还是我必须有点生气然后“撤消”所有转换工作?

编辑:因此,在另一台计算机上,我创建了一个新的ASP.NET Framework Web App和两个类库(一个.NET Framework 4.7.2和一个.NET Standard 2.1。)。我能够进入这两个类库,因此这似乎不是由于新的csproj格式本身引起的。

回到我有问题的解决方案,我可以看到.NET Standard Class lib在bin文件夹中有一个.PDF文件,但调试器输出显示:

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

仅启用我的代码,但是我认为“模块已优化”是真正的问题。我正在编译为DEBUG而不是Release。我需要在“ .NET Standard Class Lib” .csproj文件中进行更改以编译DEBUG版本而不进行优化的任何想法吗?

谢谢克里斯

c# asp.net .net-4.0
1个回答
0
投票

因此,如开头问题中所述,“构建输出”显示这些模块未加载符号,因为输出已“优化”(GB已优化)。

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

颠倒这两个问题(DEBUG配置)解决了所提出的问题。但是,“优化代码”似乎不是特定于配置的,并且在更改后查看基础的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>
© www.soinside.com 2019 - 2024. All rights reserved.