Why does Visual Studio use project templates?

I think I’m missing something regarding how visual studio works.

I’m coming from visual studio code and I can’t seem to figure out how to write a code file from scratch without having to pick a project template when you choose start projects.

I don’t want templates I want to work from scratch.

Am I missing something?

2 Likes

You can create an empty solution and then add projects to it. But yeah, tbh from there I don´t know how to create a completely blank project without manually creating it either.

Console apps are the closest you can get to an empty solution it just generates Console.WriteLine("Hello World") as a one liner now.


When you double click the project you created on top it will show this in case you created any web api project.

<Project Sdk="Microsoft.NET.Sdk.Web">

There are a bunch of these .NET project SDK overview | Microsoft Docs

If you create a straight console app it will only add the .net sdk, which is the most basic and .net.sdk.web depends on it too.

<Project Sdk="Microsoft.NET.Sdk">

Not sure of a complete list of what these change. They impact implicit usings. Depending on your SDK type some using you just don´t have to write. From what I can see also what file types it will implicitly just do xyz thing with. As in if you have a razor project and you add a .cshtml it will not have to be mentioned in your poject file. If you create a console app you can totally achieve the same, but your project file will be bigger and your using will be more.

For the most part this to me seems more of a maintainability thing. Trying to keep boilerplate down for the project type you have created by providing sane defaults. There might be some outlyers like blazor client side where the sdk might be important for it to work at all. I have not specifically tested this. But for instance I do have rest apis that use razor tempates to render emails. They do not use the razor sdk.


It is a bit annoying that you have to delete WeatherForecastService every time you create an application. I agree on that. But for most project templates (unless you tick a million boxes in the wizard) it doesn´t really generate a whole lot. The main useful things it does imo is picking the correct sdk for you.

1 Like

What kind of code do you want to write?

Something needs to run the code you write. The simplest is a console application project type.

I understand that. I’m just used to text editors where I just open a file and save it in the language I want.

I really need to delve deeper into visual studio I guess.

It might be difficult to tell the difference at this point, but if you pick one particular platform or language, and are continually running into things like this which just don’t make any sense there may be more to that than just inexperience.

Some people are nuts and will take absolutely anything you throw at them. Most people will tend to gravitate to one area of the stack more than others. Working on stuff outside your wheelhouse can sometimes feel like you’re pulling teeth all day long… which sucks.

Many developers end up inheriting applications in one way or another and don’t really have a choice, but you do. Take advantage of that while you still can.

For the most part you can do that now since .net core but I’m guessing with visual studio they did not want to change so much compared to old .net so some c# devs don’t get alianated.

The old .net was literally completely unmanageable without an IDE i would say.

I’m at this annoying phase where I would like to find one editor to use and learn and stick with it.

For compiled languages you’ll probably want to stick with an IDE. IDEs are dicks(Hey! That’s wrong! Let me show you this useful dropdown of somewhat related stuff right on top of what you’re typing. Nope! Still wrong!.. Oh, nevermind.), but if there’s a better alternative I haven’t found one.

For shell scripting, and any other interpreted languages just find a text editor you like and go with that. Everyone has a different one. I’ve been using Atom for a while now and it seems pretty good. For more sysadmin type stuff where I don’t have a GUI I’ll use vi(m) just because it’s installed by default on just about everything.

There are blank project templates which is just an empty project.

and can add blank files as well.

2 Likes

Thanks! That really helped me a lot.

1 Like

You could also try Jetbrains Rider. Another C# ide. Just the fact that they have a bajillion IDEs that all look/work the same and work on every OS makes those very attractive. Unfortunately, i can´t choose my IDE at work. Rider also costs money unlike visual studio for small teams.

They are also making this thing right now JetBrains Fleet: The Next-Generation IDE by JetBrains. It´s in closed preview. Not sure wether it will cost anything, or if there will be a free version. Can´t try it either. But seems cool. Kinda like vscode, but more ide like. One IDE for all the languages. Especially when you write your frontend and backend in different languages. Presumably that would allow you to have them open at the same time in the same IDE.

Interesting I was only aware of blank solution. Not blank project.

Hi,
The Visual Studio SDK includes project templates that create a custom project template and a custom item template. This lets you implement version control on the source files and build a group of template projects into one VSIX package. You can also configure a template to install NuGet packages.