Can I use .net core on visual studio 2013 - visual-studio-2013

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

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.

An empty ASP.NET Core application can be built in VS2013 by doing the following steps:
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).
Install the following NuGet Packages:
Microsoft.AspNetCore.Hosting
Microsoft.AspNetCore.Server.Kestrel
Add existing item to project: [solution root]\packages\Libuv.[version]\runtimes\[os]\native\libuv.dll.
For the above file, set the property "Copy to Output Directory" to "Copy always"
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!");
});
}
}

Related

Program does not contain a static 'Main' method suitable for an entry point In .Net MAUI Xunit

I am getting "Program does not contain a static 'Main' method suitable for an entry point" error while run the Xunit project in .NET MAUI
public class UnitTest1
{
[Fact]
public void Test1()
{
}
}
Reproduce :
Create an MAUI application and add a new project XUnit to the solution.
Reference the MAUI project to the XUnit project.
Run the Test cases then get the above exception.
Using Visual Studio 17.3 Preview 2.0
You need to make a few modifications to make xUnit work. I have a sample repository here: https://github.com/jfversluis/MauiUnitTestSample
All the modifications are in the csproj files of both projects and marked with a comment that starts with xUnit.
Add net6.0 as a target in your .NET MAUI project.
<!-- xUnit: Add net6.0; here -->
<TargetFrameworks>net6.0;net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
Make the OutputType of the .NET MAUI project exclude the net6.0 target
<!-- xUnit: The condition here only excludes this for the unit test project -->
<OutputType Condition="'$(TargetFramework)' != 'net6.0'">Exe</OutputType>
In your xUnit project add UseMaui if you need to reference .NET MAUI APIs
<!-- xUnit: Add UseMaui if you need access to .NET MAUI APIs-->
<UseMaui>true</UseMaui>
You should now be able to add and run unit tests!

Can't Add Reference to MVC 6 Project (.Net Core w/ .Net Framework) from Another Project

I'm running Visual Studio 2015 Update 3. I chose to create a .Net Core Project with .Net framework option specifically to use MVC 6. I have some classes in the project that I would like to reference from a console application project that I have included in the same solution. Although I can successfully add a reference to the .Net Core Project from the Console App, when I try to use the class from the console app, i'm unable to successfully add a using statement. It was my understanding that using the project template .Net Core App "With Net Framework" would prevent such issues. I've seen other posts regarding csproj xproj incompatibility. But i'm trying to add the reference from one xproj to another xproj. Is this even supported anymore? What a mess.
FYI: I also disabled resharper.
add the reference from one xproj to another xproj
If I understand correctly, the projects you are trying to link are both using project.json, right? This can be done by editing the project.json files. For example, you have "WebApp" and want to reference "ClassLib", edit the project.json file in the "WebApp" project to contain:
{
"dependencies": {
"ClassLib": {
"type": "project"
}
}
}
This part assumes that "ClassLib" is targeting a framework that is compatible with "WebApp", as listed in the "frameworks" section in project.json If your WebApp is targeting .NET Framework 4.6 (net46), then Class Lib should also target net46 or one of the frameworks compatible with "net46", such as "net451" or "netstandard1.3".

Breakpoint put in decompiled assembly from .Net Reflector is never hit while debugging in Visual Studio

First, I created a testing assembly HelloWorld.dll which I want to debug and built it with release configuration.
namespace HelloWorld
{
public class HelloClass
{
public string SayHello(string name)
{
return "Hi " + name + "!";
}
}
}
Then I created standart ASP.NET MVC project and:
Referenced HelloWorld.dll assembly
Modified HomeController's About method
public ActionResult About()
{
var testingClass = new HelloClass();
ViewBag.Message = testingClass.SayHello("John");
return View();
}
Via .NET Reflector Object Browser decompiled HelloWorld assembly
Put breakpoint inside SayHello method (in decompiled file)
Run debug in IIS express or IIS and request ~/Home/About page
Result: Brekpoint is never hit.
When I go to Debug -> Windows -> Modules it seems that symbols for HelloWorld.dll assembly was loaded:
So, what am I doing wrong?
EDIT: I am using Visual Studio 2015 Update 1 and RedGate Reflector 8.5
After hours and hours of research and contacting RedGate support it seems to be a bug in their software.
Workarounds:
Use Visual Studio 2013, where it works as expected
In VS 2015 go to .NET Reflector -> Generate PDBs and select C# version to v4.5. Reflector has some problems with C# version v4.6

.Net framework prerequisite (4.5.2) in Visual Studio 2013 setup project doesn't work

I am using Visual Studio 2013 and the setup extension to create my installer. I am setting .Net 4.5.2 as prerequisite but this doesn't prompt the user to install .Net framework 4.5.2 at installation. Anyone else faced similar issue or can suggest any solution.
The prerequisite of .Net Framework 4.5.2 doesn't work in the setup project extension of VS2013, but I found a workaround to make it working.
To make it work you can edit the .vdproj manually.
You need to edit the below mentioned tag in .vdproj file from:
"LaunchCondition"
{
"{A06ECF26-33A3-4562-8140-9B0E340D4F24}:_BD8A05B1D41349D39EF455D73B3E0C43"
{
"Name" = "8:.NET Framework"
"Message" = "8:[VSDNETMSG]"
"FrameworkVersion" = "8:.NETFramework,Version=v4.0,Profile=Client"
"AllowLaterVersions" = "11:FALSE"
"InstallUrl" = "8:http://go.microsoft.com/fwlink/?LinkId=131000"
}
}
to:
"LaunchCondition"
{
"{A06ECF26-33A3-4562-8140-9B0E340D4F24}:_BD8A05B1D41349D39EF455D73B3E0C43"
{
"Name" = "8:.NET Framework"
"Message" = "8:[VSDNETMSG]"
"FrameworkVersion" = "8:.NETFramework,Version=v4.5.2"
"AllowLaterVersions" = "11:FALSE"
"InstallUrl" = "8:https://www.microsoft.com/en-in/download/details.aspx?id=42642"
}
}
Basically you need to change the .net framework version and link to download the .net framework 4.5.2

FilterConfig in visual studio 2015

I am trying to migrate my asp.net mvc web api project to visual studio 2015 preview version.
I am not finding a way to adopt the FilterConfig.cs code on visual studio 2015 since the 2015 version doesn't going to support global.asax, web.config.
So where i can put my filterconfig, areaconfig.
You need to register your filters in the StartUp class, inside the ConfigureServices method:
public void ConfigureServices(IServiceCollection services)
{
// Add MVC services to the services container.
services.AddMvc().Configure<MvcOptions>(options =>
{
options.Filters.Add(typeof (MyGlobalFilterAttribute));
});
}

Resources