Skip to content

Commit

Permalink
Merge pull request #131 from NSwag/master
Browse files Browse the repository at this point in the history
Added NSwag.MSBuild
  • Loading branch information
RicoSuter committed May 20, 2016
2 parents 96dbf1b + 3e873a5 commit ba09701
Show file tree
Hide file tree
Showing 8 changed files with 627 additions and 573 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## NSwag: The Swagger API toolchain for .NET and TypeScript

[![NuGet Version](https://badge.fury.io/nu/nswag.core.svg)](https://www.nuget.org/packages?q=NSwag)
[![Gitter](https://img.shields.io/badge/gitter-join%20chat-1dce73.svg)](https://gitter.im/NSwag/NSwag)
[![NuGet Version](https://badge.fury.io/nu/nswag.core.svg)](https://www.nuget.org/packages?q=NSwag)
[![Build status](https://ci.appveyor.com/api/projects/status/aajfgxqf5dic7tkk?svg=true)](https://ci.appveyor.com/project/rsuter/nswag)
CI: [![Build status](https://ci.appveyor.com/api/projects/status/sfoha01b3i841iky?svg=true)](https://ci.appveyor.com/project/rsuter/nswag-25x6o)

Expand All @@ -15,6 +15,7 @@ The NSwag project heavily uses [NJsonSchema for .NET](http://njsonschema.org) fo
- In your C# code, via [NuGet](https://www.nuget.org/packages?q=NSwag)
- Via [command line](https://github.com/NSwag/NSwag/wiki/CommandLine) (Windows, Mac and Linux support through [Mono](http://www.mono-project.com/))
- Generate code with [T4 templates](https://github.com/NSwag/NSwag/wiki/T4) in Visual Studio
- In your [MSBuild targets](https://github.com/NSwag/NSwag/wiki/MSBuild)

**Swagger Generators:**

Expand Down Expand Up @@ -52,6 +53,7 @@ The NSwag project heavily uses [NJsonSchema for .NET](http://njsonschema.org) fo
- [NSwag.Annotations](https://www.nuget.org/packages/NSwag.Annotations/) (PCL 259): Attributes to decorate Web API controllers to control the Swagger generation ([Source Code](https://github.com/NSwag/NSwag/tree/master/src/NSwag.Annotations))
- [NSwag.CodeGeneration](https://www.nuget.org/packages/NSwag.CodeGeneration/) (PCL 259): Classes to generate C# and TypeScript clients ([Source Code](https://github.com/NSwag/NSwag/tree/master/src/NSwag.CodeGeneration))
- [NSwag.AssemblyLoader](https://www.nuget.org/packages/NSwag.AssemblyLoader/) (.NET 4.5+): Classes to load assemblies in an isolated AppDomain and generate Swagger specs from Web API controllers
- [NSwag.MSBuild](https://www.nuget.org/packages/NSwag.MSBuild/) (MSBuild .targets): Adds a .targets file to your Visual Studio project, so that you can run the NSwag command line tool in a MSBuild target

### Usage in C#

Expand Down
30 changes: 30 additions & 0 deletions src/NSwag.MSBuild/NSwag.MSBuild.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>NSwag.MSBuild</id>
<version>2.32</version>
<authors>Rico Suter</authors>
<owners>Rico Suter</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<licenseUrl>https://github.com/NSwag/NSwag/blob/master/LICENSE.md</licenseUrl>
<projectUrl>https://github.com/NSwag/NSwag</projectUrl>
<iconUrl>https://raw.githubusercontent.com/NSwag/NSwag/master/assets/NuGetIcon.png</iconUrl>
<description>NSwag: The Swagger API toolchain for .NET</description>
<tags>Swagger Documentation WebApi AspNet TypeScript CodeGen</tags>
<developmentDependency>true</developmentDependency>
<dependencies />
<references />
</metadata>
<files>
<file src="NSwag.MSBuild.targets" target="build" />
<file src="..\NSwag\bin\Release\NConsole.dll" target="build" />
<file src="..\NSwag\bin\Release\Newtonsoft.Json.dll" target="build" />
<file src="..\NSwag\bin\Release\NJsonSchema.CodeGeneration.dll" target="build" />
<file src="..\NSwag\bin\Release\NJsonSchema.dll" target="build" />
<file src="..\NSwag\bin\Release\NSwag.AssemblyLoader.dll" target="build" />
<file src="..\NSwag\bin\Release\NSwag.CodeGeneration.dll" target="build" />
<file src="..\NSwag\bin\Release\NSwag.Core.dll" target="build" />
<file src="..\NSwag\bin\Release\NSwag.exe" target="build" />
<file src="..\NSwag\bin\Release\NSwag.exe.config" target="build" />
</files>
</package>
6 changes: 6 additions & 0 deletions src/NSwag.MSBuild/NSwag.MSBuild.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<NSwagExe>$(MSBuildThisFileDirectory)\NSwag.exe</NSwagExe>
</PropertyGroup>
</Project>
Binary file added src/NSwag.MSBuild/NuGet.exe
Binary file not shown.
2 changes: 2 additions & 0 deletions src/NSwag.MSBuild/build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mkdir Output
nuget pack NSwag.MSBuild.nuspec -OutputDirectory Output
8 changes: 8 additions & 0 deletions src/NSwag.sln
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{B50A
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NSwag.AssemblyLoader", "NSwag.AssemblyLoader\NSwag.AssemblyLoader.csproj", "{46634C60-BA7D-43E6-9049-6AD461488C39}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NSwag.MSBuild", "NSwag.MSBuild", "{0CBA6B21-C510-441F-A37F-6B74D504B966}"
ProjectSection(SolutionItems) = preProject
NSwag.MSBuild\build.bat = NSwag.MSBuild\build.bat
NSwag.MSBuild\NSwag.MSBuild.nuspec = NSwag.MSBuild\NSwag.MSBuild.nuspec
NSwag.MSBuild\NSwag.MSBuild.targets = NSwag.MSBuild\NSwag.MSBuild.targets
NSwag.MSBuild\NuGet.exe = NSwag.MSBuild\NuGet.exe
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
6 changes: 6 additions & 0 deletions src/NSwag/Commands/Base/OutputCommandBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ protected void WriteOutput(IConsoleHost host, string output)
host.WriteMessage(output);
else
{
var file = new FileInfo(OutputFilePath);
var directory = file.Directory;

if (!directory.Exists)
directory.Create();

File.WriteAllText(OutputFilePath, output, Encoding.UTF8);
host.WriteMessage("Code has been successfully written to file.\n");
}
Expand Down
Loading

0 comments on commit ba09701

Please sign in to comment.