0

We are in process of building a new WebApi. We started out with using .Net Core Rc1 before summer holidays - and now, with .Net Core being 1.0 I would like to update.

But I run into some issues - which I can't figure out if I can solve?

The challenge is that I need to reference some .Net 4.5.1 x86 assemblies.

This means I need to use a moniker that allows use of .Net 4.5.1 - and if I need both worlds, as I understand it - only netstandard16 is available. (https://learn.microsoft.com/da-dk/dotnet/articles/standard/library)

But then I run into the issue that .Net 4.6.3 (or vNext in the above link) is not available yet.

If I reference netstandard15 - then AspNetCore libraries won't work.

If I reference netstandard16 - then I get the following errors

error : Can not find runtime target for framework '.NETStandard,Version=v1.6' compatible with one of the target runtimes: 'win10-x64, win81-x64, win8-x64, win7-x64'. Possible causes:
error : 1. The project has not been restored or restore failed - run `dotnet restore`
error : 2. The project does not list one of 'win10-x64, win81-x64, win8-x64, win7-x64' in the 'runtimes' section.
error : 3. You may be trying to publish a library, which is not supported. Use `dotnet pack` to distribute libraries.

Is it at all possible with current available bits to do the following

  • Have a business layer in .Net 4.5 compiled for x86 (need to reuse this - legacy is great)
  • Create a Asp.Net Core site
  • Reference the business Layer in site - and just carry on coding

Is anyone able to help me out here?

EDIT: The project.json (in two versions)

From RC1

{
  "version": "1.0.0-*",
  "compilationOptions": {
    "emitEntryPoint": true
  },

  "dependencies": {
    "AutoMapper": "4.2.1",
    "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
    "Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
    "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final",
    "Swashbuckle.SwaggerUi": "6.0.0-rc1-final",
    "Swashbuckle.SwaggerGen": "6.0.0-rc1-final"
  },

  "commands": {
    "web": "Microsoft.AspNet.Server.Kestrel"
  },

  "frameworks": {
    "dnx451": {
      "dependencies": {
        "BaseClasses": "1.0.0-*",
        "DatabaseAccessCS": "1.0.0-*",
        "BusinessLogic": "1.0.0-*",
        "StandardFunctionsCS": "1.0.0-*"
      },
      "frameworkAssemblies": {
        "System.configuration": "4.0.0.0"
      }
    }
  },

  "exclude": [
    "wwwroot",
    "node_modules"
  ],
  "publishExclude": [
    "**.user",
    "**.vspscc"
  ]
}

The attempt on final 1.0 that came closest to working

{
  "version": "1.0.0-*",
  "buildOptions": {
    "debugType": "portable",
    "emitEntryPoint": true
  },
  "dependencies": {
    "AutoMapper": "5.1.1",
    "Microsoft.AspNetCore.Mvc": "1.0.0",
    "Microsoft.AspNetCore.Mvc.Core": "1.0.0",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Logging": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Logging.Debug": "1.0.0",
    "Swashbuckle.SwaggerGen": "6.0.0-beta902",
    "Swashbuckle.SwaggerUi": "6.0.0-beta902"
  },
  "frameworks": {
    "netstandard16": {
      "dependencies": {
        "BaseClasses": {
          "target": "project"
        },
        "DatabaseAccessCS": {
          "target": "project"
        },
        "BusinessLogic": {
          "target": "project"
        },
        "StandardFunctionsCS": {
          "target": "project"
        }
      }
    }
  }
}

Final json that works

{
  "version": "1.0.0-*",
  "buildOptions": {
    "debugType": "portable",
    "emitEntryPoint": true,
    "platform": "x86"
  },
  "runtimes": {
    "win":  ["win7-x86", "win8-x86", "win10-x86"]
  },
  "dependencies": {
    "AutoMapper": "5.1.1",
    "LogiholdBusinessObjects": "5.5.0",
    "Microsoft.AspNetCore.Mvc": "1.0.0",
    "Microsoft.AspNetCore.Mvc.Core": "1.0.0",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Logging": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Logging.Debug": "1.0.0",
    "Swashbuckle.SwaggerGen": "6.0.0-beta902",
    "Swashbuckle.SwaggerUi": "6.0.0-beta902"
  },
  "frameworks": {
    "net451": {
      "frameworkAssemblies": {
        "System.Configuration": "4.0.0.0"
      }
    }
  }
}
1
  • can you please share your project.json? Commented Sep 14, 2016 at 8:26

1 Answer 1

1

If you want a .NET Core appliction, you should use the netcoreapp1.0 target framework. You probably won't be able to reference the .NET 4.5.1 library in the .NET Core app.

You could also target a desktop (full) .NET Framework like this:

"frameworks": {
  "net451": { }
}

Now you can use .NET 4.5.1 library but your application won't run on the .NET Core runtime anymore.

You could also target a higher version of .NET, just like `net461 for example.

Sign up to request clarification or add additional context in comments.

6 Comments

But.. If I target net451 i can't use the Microsoft.AspNetCore assemblies right?
In RC1 I could use both worlds together and it worked fine.
You can, ASP.NET MVC Core still targets both full .NET and .NET Core.
I could have sworn I tried that yesterday - and had some troubles - but for now, it actually seems to resolve, and compile. I will test it out a bit, and convert the remaining code and get back to hopefully close the thread.
I'm a bit stuck with the references. The "old" assemblies build to a common folder in a parent folder to the csproj file - somehow I am missing something as the project reference fails to resolve this path, but keeps looking in e.g. MyCode\BaseClasses\bin\debug\BaseClasses.dll instead of MyCode\bin\debug\BaseClasses. Will return once I figure that out.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.