VSCode 中的 XML 调试器

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

我有一个 csproj 文件,我相信该文件是为了在同一目录中编译大量 C# 程序而创建的,但我在运行它时遇到了问题,因为我一直被要求使用 XML 调试器。当 VSCode 要求查找 XML 调试器时,它提供的选项不是 XML 调试器,并且不相关。我尝试过安装 XML 插件,例如 Red Hat 的 XML 和 Josh Johnson 的 XML Tools,但似乎都没有被识别为调试工具。通过设置 JSON 将其中一个插件列为默认格式化程序也没有任何结果。我什至没有看到 XML 环境,但我不知道这是否有必要。我还尝试重新安装 VSCode 并删除并重新安装所有插件,但这并没有产生任何结果。我需要做什么才能正确运行该文件?

请耐心等待,因为我对 XML 和 C# 都是新手,我的大部分编码经验都是在 Python 中完成的,只是试图修复一些在我开始工作前几年在工作中创建的宏的一些问题。

尝试运行时遇到错误

.csproj 文件:

 <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.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>{CC048C24-CAA0-48E8-95E9-A2EC5E1FF435}</ProjectGuid>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>BOMLib</RootNamespace>
    <AssemblyName>BOMLib</AssemblyName>
    <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <Deterministic>true</Deterministic>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="EPPlus, Version=4.5.3.1, Culture=neutral, PublicKeyToken=ea159fdaa78159a1, processorArchitecture=MSIL">
      <HintPath>..\..\..\packages\EPPlus.4.5.3.1\lib\net40\EPPlus.dll</HintPath>
    </Reference>
    <Reference Include="PresentationCore" />
    <Reference Include="System" />
    <Reference Include="System.configuration" />
    <Reference Include="System.Core" />
    <Reference Include="System.Drawing" />
    <Reference Include="System.Security" />
    <Reference Include="System.Threading.Tasks" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Data" />
    <Reference Include="System.Net.Http" />
    <Reference Include="System.Xml" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="BOMItem.cs" />
    <Compile Include="BOMKeys.cs" />
    <Compile Include="IBOMFilter.cs" />
    <Compile Include="BOMTemplate.cs" />
    <Compile Include="Internal\BOMLocationData.cs" />
    <Compile Include="Internal\StyleCopyTools.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
    <Compile Include="Properties\Resources.Designer.cs">
      <AutoGen>True</AutoGen>
      <DesignTime>True</DesignTime>
      <DependentUpon>Resources.resx</DependentUpon>
    </Compile>
  </ItemGroup>
  <ItemGroup>
    <None Include="packages.config" />
    <None Include="Resources\BOMTemplate.xlsx" />
  </ItemGroup>
  <ItemGroup>
    <EmbeddedResource Include="Properties\Resources.resx">
      <Generator>ResXFileCodeGenerator</Generator>
      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
    </EmbeddedResource>
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
xml visual-studio-code vscode-debugger csproj
3个回答
0
投票

您不运行/调试 .csproj 文件。 您运行/调试包含

Main
方法的 .cs 代码文件。


0
投票

这个问题类似的解决方案对我有用。 转到运行 > 添加配置 > 选择您的语言


0
投票

首次调试/运行项目之前:-

  1. 首先关注资源管理器树
  2. 开始调试/运行。
  3. VS Code 会要求您从已安装的调试器中选择一个调试器。
  4. 选择 C#。
© www.soinside.com 2019 - 2024. All rights reserved.