Skip to content

SDK Development

Rico Suter edited this page Dec 13, 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)
  • The latest version of the .NET Core SDK
  • (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

Release new version

  • With Visual Studio Code search for the current version and replace with the new version
    • With the following file includes: *.csproj,*.nuspec,package.json,AssemblyInfo.cs
  • Commit with the name v1.2.3, create a PR and merge into master, then into release