Skip to content

SDK Development

Rico Suter edited this page Nov 5, 2018 · 12 revisions

Required tools and SDKs

To develop the NSwag toolchain, you need the following tools and SDKs:

  • Visual Studio 2017
    • ".NET desktop development" workload (required for WPF projects [i.e. NSwagStudio])
    • "ASP.NET and web development" workload (required for ASP.NET projects)
    • ".NET Core cross-platform development" workload (required for .NET Core projects)
  • (optional) Wix Toolset (required to build the MSI installer)
  • (optional) NodeJS (required to build the NSwag.Npm package)

Execute from Visual Studio

There are two solutions:

  • NSwag.sln: The complete solution with all frontends
    • The NSwagStudio.Installer project compiles the NSwag console binaries used by NSwagStudio
    • NSwagStudio only calls the console binaries, so the actual generators cannot be debugged when starting NSwagStudio
    • We recommend to create an nswag.json config file and test by starting NSwag.ConsoleCore with Project properties > Debug > Application arguments: run "path/to/my/nswag.json"
  • NSwag.Min.sln: Contains only SDK-style projects without the NSwagStudio and NSwagStudio.Installer (much better performance)

Reference NJsonSchema with project references

The DTO classes (e.g. request/response classes) to JSON Schema conversion and code generation is implemented in NJsonSchema.

Often, a code change requires changes in NJsonSchema and NSwag and thus it is nice to have all libraries in one solution (i.e. resolve NuGet references to project references). For this I use the DotNetTools CLI commands switch-to-projects and switch-to-packages with the switcher.json config file. This only works in the NSwag.Min.sln solution.

Add a new runtime

  • Update NSwagStudio nswag.cmd
  • Add new enum value to NSwag.Commands.Runtime
  • Add new target framework to NSwag.ConsoleCore project
  • Add new runtime to the NSwagStudio.Installer project's build events
  • TBD