Reputation: 207
In my visual studio code project, I have generated an .exe
file for the project and I'm trying create make my .exe
as Windows Service.
From here and here, if I'm not mistaken, these solutions look like done by using Visual Studio instead of Visual Studio Code. Is it possible to create a Window Service through Visual Studio Code?
Upvotes: 2
Views: 8007
Reputation: 1113
Although this is quite an old answer I want to revive it because it pops up in a Google search as one of the first hits and the accepted answer is a bit misleading.
You don't need Visual Studio as Ben Voigt wrote. Visual Studio Code is just fine, but neither VS Code nor the .NET Package have build in projects for a windows service. This does not mean you cannot use VS Code for this. You can check available solutions with, maybe in the future there will be project template:
dotnet new list
As of now you will have to create the files for yourself, just create a new, empty project in VS Code and add the files and classes needed for a windows service. With the above command you will see an empty project for .NET Core is created by:
dotnet new web
In this project you will have to create the classes needed for the compilation of a windows service.
The search terms "c# windows service skeleton" will give you solutions. For example the code project site: https://www.codeproject.com/Articles/14353/Creating-a-Basic-Windows-Service-in-C
Upvotes: 1
Reputation: 81593
You cant,
Visual Studio Code is a code editor redefined and optimized for building and debugging modern web and cloud applications. Visual Studio Code is free and available on your favorite platform - Linux, Mac OSX, and Windows.
It has no concept of an Windows Service
If you wish to create a Windows service you will have to use Visual Studio or something that can compile standard .net Windows application
Great comment from Ben Voigt
You're correct that Visual Studio Code doesn't have a concept of a service, but that's because it is an editor not a compiler. The same C# compiler installed as part of the .NET runtime, can build Windows Services. And you can edit the windows service code in VS Code
Upvotes: 7