生成项目的XML文档注释

huangapple go评论58阅读模式
英文:

Generating XML documentation for a project

问题

我正在使用Visual Studio中的VB.NET编程,并希望生成XML文档。我使用神奇的'''注释来从我的源代码生成xml。当我转到项目属性并在“Compile->General”选项卡中勾选“Generate XML documentation file”时,每次单击它时,它都会消失。你知道为什么吗?是否有另一种方法,例如通过将一些XML添加到vbproj文件中?

生成我的项目的XML文档文件。

英文:

I am programming in VB.NET in Visual Studio and wants to generate XML documentation. I use the magical ''' comments to generate xml from my source code. When I go to the Project Properties and check the Generate XML documentation file in the Compile->General tab, each time I click it, it disappears. Do you know why ? Is there another way, for example by adding some xml into the vbproj file ?

To generate xml documentation file from my project.

答案1

得分: 4

我看到了您描述的与.NET Core应用程序相同的行为。这可能是VS中的一个错误或他们尚未完全实现的问题。我已经确定了一个手动解决方法。

当我首次创建一个项目时,在属性中看到的是这样的:
生成项目的XML文档注释

如果我查看项目文件,我会看到这样:

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'" />

在.NET Framework项目中,默认情况下选中了等效的框,我会看到这样:

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
  <DocumentationFile>WindowsApp1.xml</DocumentationFile>
</PropertyGroup>

无关的行已被删除。

如果我将我的.NET 6项目更改为这样:

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
  <DocumentationFile>WinFormsApp1.xml</DocumentationFile>
</PropertyGroup>

然后项目属性会更改为这样:
生成项目的XML文档注释

您还可以为 Release 添加一个单独的 PropertyGroup 元素。或者,如果只是将该子元素添加到顶部没有 Condition 属性的 PropertyGroup 中,那么它将显然适用于所有生成配置,并且您将得到这样的结果:
生成项目的XML文档注释

似乎该框忠实地表示了对项目文件的读取,但未能正确触发写入。

英文:

I'm seeing the same behaviour that you describe for a .NET Core app. This may be a bug in VS or just something they haven't got around to implementing properly yet. I have determined a manual workaround though.

When I first create a project, this is what I see in the properties:

生成项目的XML文档注释

If I look at the project file, I see this:

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'" />

In a .NET Framework project, the equivalent box is checked by default and I see this:

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
  <DocumentationFile>WindowsApp1.xml</DocumentationFile>
</PropertyGroup>

Irrelevant lines have been removed.

If I change my .NET 6 project to this:

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
  <DocumentationFile>WinFormsApp1.xml</DocumentationFile>
</PropertyGroup>

then the project properties changes to this:

生成项目的XML文档注释

You can add a separate PropertyGroup element for Release too. Alternatively, if you just add that child element to the top PropertyGroup that has no Condition attribute then it will apparently apply to all build configurations and you'll get this:

生成项目的XML文档注释

It seems that that box faithfully represents a read of the project file but doesn't trigger a write properly.

huangapple
  • 本文由 发表于 2023年5月21日 12:31:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/76298308.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定