Can I use .net core on visual studio 2013

2019-01-23 23:49发布

Is, or will .net core be available to use on visual studio 2013? Or it will be available only on visual studio 2015?

Thanks

2条回答
等我变得足够好
2楼-- · 2019-01-24 00:20

An empty ASP.NET Core application can be built in VS2013 by doing the following steps:

  1. Create a Console App project that targets at least .NET Framework 4.5.2 (using 4.5.1 is possible but support has now ended).
  2. Install the following NuGet Packages:
    • Microsoft.AspNetCore.Hosting
    • Microsoft.AspNetCore.Server.Kestrel
  3. Add existing item to project: [solution root]\packages\Libuv.[version]\runtimes\[os]\native\libuv.dll.
  4. For the above file, set the property "Copy to Output Directory" to "Copy always"
  5. Produce the necessary Startup.cs and Program.cs files

Basic Code (from the Getting Started Tutorial):

Program.cs

public class Program
{
    public static void Main(string[] args)
    {
        var host = new WebHostBuilder()
            .UseKestrel()
            .UseStartup<Startup>()
            .Build();

        host.Run();
    }
}

Startup.cs

public class Startup
{
    public void Configure(IApplicationBuilder app)
    {
        app.Run(context =>
        {
            return context.Response.WriteAsync("Hello from ASP.NET Core!");
        });
    }
}
查看更多
forever°为你锁心
3楼-- · 2019-01-24 00:40

Yes, it's possible to build against the .NET Core 5 contracts in Visual Studio 2013 by creating a Portable Class Library that targets .NET Framework 4.5 and Windows 8. You'll need to manually edit the .csproj file and add the following.

<PropertyGroup>
    <ImplicitlyExpandTargetFramework>false</ImplicitlyExpandTargetFramework>
</PropertyGroup>

Then install the System.Runtime NuGet package and other .NET Core 5 packages.

The resulting assembly will be able to execute on any .NET Core 5-based framework including .NET Framework 4.6, ASP.NET 5 & .NET Native.

Note, this is the same technique used to build the .NET Core assemblies in the corefx repository.

查看更多
登录 后发表回答