1

It might be a dumb question: I've created a project with Visual Studio using the ASP.NET framework, but I don't have Visual Studio on my work machine, so I'm using Visual Studio Code.

How can I run that project? Or even, create a new one using the structure of ASP.NET framework without the Visual Studio templates? I used to build and run using Visual Studio.

I've downloaded .NET Core SDK and .NET Framework dev pack.

I tried running a new build with console commands like dotnet build, but since it's part of the .NET Core SDK, I was already expecting it to fail with an error that says

Error MSB4019: the imported project "C:\Program Files\dotnet\sdk\7.0.306\Microsoft\VisualStudio\v17.0\We bApplications\Microsoft.WebApplication.targets" could not be located. confirm the expression in the import declaration "C:\Program Files\dotnet\sdk\7.0.306\Microsoft\VisualStudio\v17.0\WebApplications\Microsoft.WebApplication.targets" is correct.

Maybe this error is showing because I'm using VS Code to run something from Visual Studio? If so, I still don't know how to create a project running on the .NET framework without using Visual Studio templates, or run it.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Lucas
  • 11
  • 1
  • 1
    Can you clarify whether you mean .NET **Framework**, which as defined [in the documentation](https://learn.microsoft.com/en-us/dotnet/core/introduction#net-history) means the Windows-only, legacy version of .NET, or .NET in general? As you've mentioned MVC 5, which is quite old, I can guess this is what you mean, but the answers will be different depending. – Tom W Aug 05 '23 at 18:15
  • 1
    Remember that there is a Visual Studio community version that is also free to handle .NET projects… – balexandre Aug 05 '23 at 18:59

2 Answers2

1

Only .NET core is supported in VS Code.

And for that.. To create a new .NET Core project in vs code, you need to have .net installed on your system. Once it is installed, you can open vs code and verify it using dotnet --version command in terminal.

Once it is done, You need to create a project folder in your system. you can create a new project in vs code using dotnet new console. It will create a console application. And to run it, you can use dotnet run command.

Note: You need to run all these command in the same project folder.

HarrY
  • 607
  • 4
  • 14
  • This won't work for .NET Framework, only .NET Core onwards. – Tom W Aug 05 '23 at 18:12
  • Oh Yes, Sorry my bad. – HarrY Aug 05 '23 at 18:18
  • This may not be what the OP means or they may not know the difference, so I've asked for clarification. If they have no particular need for an old version this may still be the right way to go. – Tom W Aug 05 '23 at 18:19
1

Visual Studio Code support building and debugging projects for the .NET Framework. (Although it is quite limited).

You can debug 64-bit applications with portable PDBs.

Here are the steps which may help you.

Install MSBuild 15 (2017). This is available as part of visual studio build tools for 2017.

This article has more details about it. https://github.com/dotnet/vscode-csharp/wiki/Desktop-.NET-Framework

You may find this stack over flow post as helpful: How to get MSBuild 15 without a full install of Visual Studio?

Daredevil
  • 732
  • 5
  • 13