Search code examples
c#visual-studiomsbuildnswag

How can I add information to an endpoint in NSwag for .NET Framework?


Pretty much the same as this question, but for .NET Framework/Webforms instead of .NET Core:

How can I add a little information to a controller endpoint, so that it is displayed in the swagger UI in .NET Framework?

Just adding doc comments does not work, and the next step in the linked answer, adding

<PropertyGroup>
  <GenerateDocumentationFile>true</GenerateDocumentationFile>
  <NoWarn>$(NoWarn);1591</NoWarn>
</PropertyGroup>

in the .csproj also doesn't work - there's no XML fie generated (but I suspect that it's a .NET Core setting anyway).

I found the doc comment documentation saying that you can create the XML file by using csc XMLsample.cs /doc:XMLsample.xml. HOWEVER, csc is called "automatically" in the C# build target, and not in my .csproj file. If there is a way to pass the /doc parameter to it, that would be a solution, but it feels like that might be the wrong way to go about it.


Solution

  • I worked on this for a whole day yesterday, but literally 10 seconds after I posted this answer I found the setting

    ProjectSettings => Build => Output => XML documentation file

    I turned that on and now it works.