Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ public void processOpts() {
String packageFolder = sourceFolder + File.separator + packageName;

supportingFiles.add(new SupportingFile("NuGet.Config", "", "NuGet.Config"));
supportingFiles.add(new SupportingFile("global.json", "", "global.json"));
supportingFiles.add(new SupportingFile("build.sh.mustache", "", "build.sh"));
supportingFiles.add(new SupportingFile("build.bat.mustache", "", "build.bat"));
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
Expand All @@ -112,13 +111,12 @@ public void processOpts() {
supportingFiles.add(new SupportingFile("gitignore", packageFolder, ".gitignore"));
supportingFiles.add(new SupportingFile("appsettings.json", packageFolder, "appsettings.json"));

supportingFiles.add(new SupportingFile("project.json.mustache", packageFolder, "project.json"));
supportingFiles.add(new SupportingFile("Startup.mustache", packageFolder, "Startup.cs"));
supportingFiles.add(new SupportingFile("Program.mustache", packageFolder, "Program.cs"));
supportingFiles.add(new SupportingFile("validateModel.mustache", packageFolder + File.separator + "Attributes", "ValidateModelStateAttribute.cs"));
supportingFiles.add(new SupportingFile("web.config", packageFolder, "web.config"));

supportingFiles.add(new SupportingFile("Project.xproj.mustache", packageFolder, this.packageName + ".xproj"));
supportingFiles.add(new SupportingFile("Project.csproj.mustache", packageFolder, this.packageName + ".csproj"));

supportingFiles.add(new SupportingFile("Properties" + File.separator + "launchSettings.json", packageFolder + File.separator + "Properties", "launchSettings.json"));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore;

namespace {{packageName}}
{
Expand All @@ -14,21 +20,17 @@ namespace {{packageName}}
/// <param name="args"></param>
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseKestrel(options =>
{
// options.ThreadCount = 4;
// options.UseHttps("cert.pfx", "certpassword");
options.NoDelay = true;
options.UseConnectionLogging();
})
.UseUrls("http://+:5000" /*, "https://+:5001" */)
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
BuildWebHost(args).Run();
}

/// <summary>
/// Build Web Host
/// </summary>
/// <param name="args"></param>
/// <returns>Webhost</returns>
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.Build();

host.Run();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<Description>{{packageName}}</Description>
<Copyright>{{packageName}}</Copyright>
<TargetFramework>netcoreapp2.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PreserveCompilationContext>true</PreserveCompilationContext>
<AssemblyName>{{packageName}}</AssemblyName>
<PackageId>{{packageName}}</PackageId>
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.3"/>
<PackageReference Include="Swashbuckle.AspNetCore" Version="1.1.0"/>
<PackageReference Include="Newtonsoft.Json" Version="10.0.3"/>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.0.1"/>
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="2.0.0"/>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.1"/>
<DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="2.0.0"/>
</ItemGroup>
</Project>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# {{packageName}} - ASP.NET Core 1.0 Server
# {{packageName}} - ASP.NET Core 2.0 Server

{{#appDescription}}
{{{appDescription}}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
# Visual Studio 15
VisualStudioVersion = 15.0.26114.2
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{AFF6BF88-8A7D-4736-AF81-31BCE86B19BD}"
ProjectSection(SolutionItems) = preProject
global.json = global.json
EndProjectSection
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "{{packageName}}", "src\{{packageName}}\{{packageName}}.xproj", "{{packageGuid}}"
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "{{packageName}}", "src\{{packageName}}\{{packageName}}.csproj", "{{packageGuid}}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -23,4 +18,4 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
EndGlobal
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,17 @@ namespace {{packageName}}
{
private readonly IHostingEnvironment _hostingEnv;

private IConfigurationRoot Configuration { get; }
private IConfiguration Configuration { get; }

/// <summary>
/// Constructor
/// </summary>
/// <param name="env"></param>
public Startup(IHostingEnvironment env)
/// <param name="configuration"></param>
public Startup(IHostingEnvironment env, IConfiguration configuration)
{
_hostingEnv = env;

var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
.AddEnvironmentVariables();
Configuration = builder.Build();
Configuration = configuration;
}

/// <summary>
Expand All @@ -62,7 +57,7 @@ namespace {{packageName}}
{
Version = "v1",
Title = "{{packageName}}",
Description = "{{packageName}} (ASP.NET Core 1.0)"
Description = "{{packageName}} (ASP.NET Core 2.0)"
});
c.CustomSchemaIds(type => type.FriendlyId(true));
c.DescribeAllEnumsAsStrings();
Expand All @@ -78,10 +73,6 @@ namespace {{packageName}}
/// <param name="loggerFactory"></param>
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory
.AddConsole(Configuration.GetSection("Logging"))
.AddDebug();

app
.UseMvc()
.UseDefaultFiles()
Expand All @@ -91,6 +82,16 @@ namespace {{packageName}}
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "{{packageName}}");
});

if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
//TODO: Enable production exception handling (https://docs.microsoft.com/en-us/aspnet/core/fundamentals/error-handling)
// app.UseExceptionHandler("/Home/Error");
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@

dotnet restore src\{{packageName}}
dotnet build src\{{packageName}}
echo Now, run the following to start the project: dotnet run -p src\{{packageName}}\project.json web.
echo Now, run the following to start the project: dotnet run -p src\{{packageName}}\{{packageName}}.csproj --launch-profile web.
echo.
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@

dotnet restore src/{{packageName}}/ && \
dotnet build src/{{packageName}}/ && \
echo "Now, run the following to start the project: dotnet run -p src/{{packageName}}/project.json web"
echo "Now, run the following to start the project: dotnet run -p src/{{packageName}}/{{packageName}}.csproj --launch-profile web"

This file was deleted.

This file was deleted.

13 changes: 4 additions & 9 deletions samples/server/petstore/aspnetcore/IO.Swagger.sln
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
# Visual Studio 15
VisualStudioVersion = 15.0.26114.2
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{AFF6BF88-8A7D-4736-AF81-31BCE86B19BD}"
ProjectSection(SolutionItems) = preProject
global.json = global.json
EndProjectSection
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "IO.Swagger", "src\IO.Swagger\IO.Swagger.xproj", "{3C799344-F285-4669-8FD5-7ED9B795D5C5}"
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "IO.Swagger", "src\IO.Swagger\IO.Swagger.csproj", "{3C799344-F285-4669-8FD5-7ED9B795D5C5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -23,4 +18,4 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
EndGlobal
2 changes: 1 addition & 1 deletion samples/server/petstore/aspnetcore/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# IO.Swagger - ASP.NET Core 1.0 Server
# IO.Swagger - ASP.NET Core 2.0 Server

This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.

Expand Down
2 changes: 1 addition & 1 deletion samples/server/petstore/aspnetcore/build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@

dotnet restore src\IO.Swagger
dotnet build src\IO.Swagger
echo Now, run the following to start the project: dotnet run -p src\IO.Swagger\project.json web.
echo Now, run the following to start the project: dotnet run -p src\IO.Swagger\IO.Swagger.csproj --launch-profile web.
echo.
2 changes: 1 addition & 1 deletion samples/server/petstore/aspnetcore/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@

dotnet restore src/IO.Swagger/ && \
dotnet build src/IO.Swagger/ && \
echo "Now, run the following to start the project: dotnet run -p src/IO.Swagger/project.json web"
echo "Now, run the following to start the project: dotnet run -p src/IO.Swagger/IO.Swagger.csproj --launch-profile web"
7 changes: 0 additions & 7 deletions samples/server/petstore/aspnetcore/global.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<Description>IO.Swagger</Description>
<Copyright>IO.Swagger</Copyright>
<TargetFramework>netcoreapp2.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PreserveCompilationContext>true</PreserveCompilationContext>
<AssemblyName>IO.Swagger</AssemblyName>
<PackageId>IO.Swagger</PackageId>
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.3"/>
<PackageReference Include="Swashbuckle.AspNetCore" Version="1.1.0"/>
<PackageReference Include="Newtonsoft.Json" Version="10.0.3"/>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.0.1"/>
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="2.0.0"/>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.1"/>
<DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="2.0.0"/>
</ItemGroup>
</Project>
Loading