Skip to content

MSBuild

Rico Suter edited this page Aug 30, 2017 · 42 revisions

Package: NSwag.MSBuild

After installing the NSwag.MSBuild NuGet package in your project, you can use the variable $(NSwagExe) in your .csproj file to run the NSwag command line tool in an MSBuild target. This way the tools can easily be updated via NuGet.

<Target Name="NSwag" AfterTargets="Build">
	<Exec Command="$(NSwagExe) webapi2swagger /assembly:$(OutDir)/MyWebAssembly.dll /controller:MyNamespace.MyController /output:swagger.json" />
	<Exec Command="$(NSwagExe) swagger2tsclient /input:swagger.json /output:Scripts/MyController.ts" />
</Target>

If you need to run the NSwag command line to in x86 mode, use the $(NSwagExe_x86) placeholder.

All available properties in NSwag.MSBuild.props

See Command Line for more information.