domaindrivendev / Swashbuckle.AspNetCore

Swagger tools for documenting API's built on ASP.NET Core
MIT License
5.22k stars 1.3k forks source link

Core, with net452 framework? #143

Closed domaindrivendev closed 5 years ago

domaindrivendev commented 8 years ago

Moving the original issue - https://github.com/domaindrivendev/Swashbuckle/issues/780 here as it's related to SB 6x and ASP.NET Core ...

I'm not seeing a way to install Swashbuckle on an Asp.Net Core application using the net452 framework.

Swashbuckle 6.0 will only install on dnx framework.

Swashbuckle 5.0 is set up for OWIN

Is it possible to get Swashbuckle on a Core/net452 application

domaindrivendev commented 8 years ago

@rynowak - any ideas? Is it as simple as adding net452 here https://github.com/domaindrivendev/Ahoy/blob/master/src/Swashbuckle.Swagger/project.json#L32

JSkimming commented 8 years ago

We're installing into an ASP.NET Core application targeting .NET 4.6.1 and it works just fine.

Given you're already targeting net451 it should work from .NET 4.5.1 through to .NET 4.6.1.

rynowak commented 8 years ago

@domaindrivendev yes - it's that simple. We go all the way down to 4.5.1 https://github.com/aspnet/Mvc/blob/dev/src/Microsoft.AspNetCore.Mvc.Core/project.json#L59

You may need some ifdefs though - #if NET451 and #if NETSTANDARD1_6 (and similar) are provided for you.

mkontula commented 7 years ago

I was trying this today, and with current rc3 package, the test project fails with following information. The test project and api application project both target net452. When I change the targets to netcoreapp1.1, the exception goes away. To me it seems something is trying reference 1.0.0.0 version of Microsoft.Extensions.DependencyInjection.Abstractions, while the version being used by Microsoft.AspNetCore.Mvc.Core & others is 1.1.1.0 or similar.

=== Pre-bind state information ===
LOG: DisplayName = Microsoft.Extensions.DependencyInjection.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
 (Fully-specified)
LOG: Appbase = file:///C:/work/Tests452/bin/Debug/net452
LOG: Initial PrivatePath = NULL
Calling assembly : Swashbuckle.AspNetCore.SwaggerGen, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d84d99fb0135530a.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\PROFESSIONAL\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\TESTWINDOW\vstest.executionengine.x86.exe.Config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Microsoft.Extensions.DependencyInjection.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
LOG: Attempting download of new URL file:///C:/work/Tests452/bin/Debug/net452/Microsoft.Extensions.DependencyInjection.Abstractions.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Minor Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
mkontula commented 7 years ago

Adding this to xunit test project's .csproj solved the issue for me. The build directory now contains a lengthy test.project.dll.config which has all the necessary binding redirects.

`

net452
<AutoGenerateBindingRedirects>True</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>True</GenerateBindingRedirectsOutputType>

`