diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java index 526fffeda18..cccc2f23bfe 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java @@ -312,6 +312,7 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen { if (optionalProjectFileFlag) { supportingFiles.add(new SupportingFile("Solution.mustache", "", packageName + ".sln")); supportingFiles.add(new SupportingFile("Project.mustache", packageFolder, packageName + ".csproj")); + supportingFiles.add(new SupportingFile("nuspec.mustache", packageFolder, packageName + ".nuspec")); if(Boolean.FALSE.equals(excludeTests)) { // NOTE: This exists here rather than previous excludeTests block because the test project is considered an optional project file. diff --git a/modules/swagger-codegen/src/main/resources/csharp/README.mustache b/modules/swagger-codegen/src/main/resources/csharp/README.mustache index bb228814338..8c08c0e8667 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/README.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/README.mustache @@ -51,6 +51,20 @@ using {{packageName}}.{{apiPackage}}; using {{packageName}}.Client; using {{packageName}}.{{modelPackage}}; ``` + + +## Packaging + +A `.nuspec` is included with the project. You can follow the Nuget quickstart to [create](https://docs.microsoft.com/en-us/nuget/quickstart/create-and-publish-a-package#create-the-package) and [publish](https://docs.microsoft.com/en-us/nuget/quickstart/create-and-publish-a-package#publish-the-package) packages. + +This `.nuspec` uses placeholders from the `.csproj`, so build the `.csproj` directly: + +``` +nuget pack -Build -OutputDirectory out {{packageName}}.csproj +``` + +Then, publish to a [local feed](https://docs.microsoft.com/en-us/nuget/hosting-packages/local-feeds) or [other host](https://docs.microsoft.com/en-us/nuget/hosting-packages/overview) and consume the new package via Nuget as usual. + ## Getting Started diff --git a/modules/swagger-codegen/src/main/resources/csharp/nuspec.mustache b/modules/swagger-codegen/src/main/resources/csharp/nuspec.mustache new file mode 100644 index 00000000000..eaf4b0e3381 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/csharp/nuspec.mustache @@ -0,0 +1,45 @@ + + + + + $id$ + {{packageTitle}} + + + $version$ + + + $author$ + + + $author$ + false + false + + + {{packageDescription}}{{#termsOfService}} + {{termsOfService}}{{/termsOfService}}{{#licenseUrl}} + {{licenseUrl}}{{/licenseUrl}} + + + + + + {{#generatePropertyChanged}} + + {{/generatePropertyChanged}} + + + + + + + + {{#generatePropertyChanged}} + + {{/generatePropertyChanged}} + + + \ No newline at end of file