Can one install a vNext (C# 6) console app as a Windows service - windows-services

In previous versions of .Net, there were some different methods of creating a project that could run as a console app or be installed as a service.
Things like TopShelf or other approaches like: .NET console application as Windows service
This is a nice convenience for development and later deployment. I put together a vNext console app using a similar approach to the accepted answer here: .NET console application as Windows service.
The issue is that vNext runs things in a different way. If you create output, it no longer gives you an exe to install. Instead you get a nuget package and a .cmd file that will tell dnx to host your application. The command file looks like:
dnx --appbase "$(dirname $0)" Microsoft.Framework.ApplicationHost My.vNext.Service $#
So my question is: Is there a way to install this thing as a Windows service given the new console application approach?

Related

Docker GetServiceReferences: The given path's format is not supported

Trying to run locally a Web MVC application using Docker. Application compiles and runs fine when Set as StartUp Project outside of the docker-compose project but fails when docker-compose is Set as StartUp Project during the build when it comes to Target DockerGetServiceReferences: with
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.VisualStudio.Docker.Compose.targets(195,5): error : The given path's format is not supported.
I have added the docker-compose through Visual Studio 2017 to an existing application as described here:
How to containerize the .NET Framework web apps with Windows Containers and Docker
I appreciate this might be quite vague so if there are any more details I could provide please let me know.
EDIT:
Adding docker-compose to just default MVC template in a new project works fine so the problem seems to be with the legacy solution. Also noticed I can't navigate docker-compose project General Properties, I get the URI formats are not supported popup error
EDIT:
Adding a brand new MVC project from the template to the solution without any references to other projects also generates the error. Could this indicate that the problem might be somewhere on the solution level?
EDIT:
I have created a new Solution file and started to migrate all the projects. This way I am successfully able to compose docker image. Once I am finished migrating all of the project I will do a comparison on .sln files and try to see what is different.

TFS Release Task to Deploy a Web Deploy Package to specific directory

I've been digging for hours and i haven't been able to find what i would think is a pretty common scenario.
I am attempting to deploy a Web Deploy Package to my existing Web Site\Web App via a TFS Release. The location of my existing Web Apps is mapped to a different drive. My source code on my web server is not in C:\inetpub lets say its in D:\MyFiles.
I'm open to using any TFS task to do this. It seems like my two options are:
Run Batch Script - point to myApp.deploy.cmd
WinRm IIS Web App Deployment
I've seen lots of examples of overriding the computer name via the setParamater file but I have not seen one example of how to set the target path for the package?
Again, i want to deploy a web package via a TFS release to D:\MyFiles. I've created the package and it deploys locally to c:inetpub, I would assume if I can get it to deploy to a specified Target location locally then when I run that same. CMD file from TFS release it will use that location on the deploy to server.
UPDATE:
So... this just started working. I'm not sure what the issue was but the WinRm Task didn't do the deploy on Friday but did the deploy on Monday. I'm thinking it may have been related to a FQDN for the server path? Honestly I'm not sure what fixed it or what to do with this post? The answer below by #Andy may help someone so I won't delete it. That link is a good one and it showed me how to perform IIS configuration with Web Deploy.
Thanks in advance,
Greg
Seems you are trying to change the physical path of an IIS site/app using MSDeploy.
Just try adding an additional command (appcmd) to the MSDeploy package manifest to change the physical path of the IIS site during the deployment:
<runcommand path="%windir%\system32\inetsrv\appcmd set app /app.name:"Default Web Site/app12" /[path='/'].physicalPath:C:\temp\app12" waitInterval="5000"/>
Refer to this article for details:
WebDeploy/MSDeploy Quick TIP: Change IIS Site/APP Physical Path with MSDeploy

How to bundle Electron application and windows service together?

I am very new with electron application. I need some help with election installation.
I have an Electron desktop application and a windows service.
I can start and stop my pre installed services by using sudo-prompt package.
I am creating windows installer by using electron-winstaller package.
But I want to bundle my windows service along with my electron application. My requirement is when I install my electron package then it should install my service also, when I uninstall my package then that service should be uninstalled.
Please help me out. Any clue, Any suggestions will be appreciated.
If you think this should be achieved with something else then please do suggest me.
Electron's windows installer packager strikes me a specific case tool that would likely hit limitations in scenarios like this. I would use a general case tool instead such as the Free and Open Source Windows Installer XML Toolset aka WiX. I would also use with that another FOSS application called Industrial Strength Windows Installer XML aka IsWiX.
WiX allows you to describe and build MSI databases using an XML/XSD domain specific language. It supports MSBuild for easy integration with your CI/CD pipeline. IsWiX* is a set of project templates and graphical designers that provide an opinionated project structuring (scaffolding) and greatly speeds up the learning curve and implementation. For example, this installer you describe could be done without writing a single line of XML.
For more information see: https://github.com/iswix-llc/iswix-tutorials
The desktop-application and windows-service tutorials should** show you everything you need to know to author this installer. Basically follow the desktop-application all the way through and then skip to the final portion of the windows-service tutorial where you define the windows service.
I'm the maintainer of IsWiX
** This assumes your service exe is a proper Windows service that interfaces with the windows service control manager. If it's really just a console app that runs as a service you will need to include a program such as srvany.exe. This will require one line of hand crafted XML to extended the service definition in the registry with the proper command line value to be passed to your exe. An example can be found here: Wix installer to replace INSTSRV and SRVANY for user defined service installation

How do i run a ServiceStack console project as a Windows Service?

I have create a ServiceStack console application that works great, but of course, I have to leave it running after triggering it from a command prompt. I want to run this as a Windows Service.
I'm reviewing this wiki page which states that you can run SS as a Windows Service.
https://github.com/ServiceStack/ServiceStack/wiki/Self-hosting
I was not totally clear on how to do this. This StarterTemplate is referenced from 2 years ago. Do I clone this project and then copy my code into it?
https://github.com/ServiceStack/ServiceStack.Examples/tree/master/src/StarterTemplates/WinServiceAppHost
The easiest way is to create a ServiceStack Windows Service Empty project in ServiceStackVS VS.NET Extension.
Otherwise you can clone the WinService project, and create a new Windows Service project from Visual Studio and copy the approach in Program.cs.
A more recent ServiceStack Windows Service project is the Razor Rockstars website running in a Windows Service Host, the template of which was based on the ServiceStack.Examples Starter template.
I use topshelf to run a servicestack console app as a windows service. It works really well for me. https://github.com/Topshelf/Topshelf

How best to install MVC 3 on a server?

Now that MVC 3 Tools Update has been released, that's all I see on the Web Platform Installer -- I no longer see MVC 3? Is this because the Tools Update is essentially MVC 3 PLUS enhancements to the development environment? Presumably, none of these additions are needed on a server so I thought that MVC 3 would still be offered for server installs.
So can/should I install the MVC 3 "Tools Update" from the Web Platform installer on a server?
I know this doesn't help you Decker, but it may help others:
The easiest way to get MVC on the server is by using the "Add Deployable Dependancies..." menu:
Also useful for deploying SQL CE.
You can use the installer from WebPI on the server just fine. It will detect if you don't have Visual Studio installed and will only install the runtime.
You could also try unzipping the installer file and only copying the runtime MSIs but I think that's overkill.
You could also use Web Platform Installer from the command line:
webpicmd /install /Products:MVC3Runtime /log:webpi.log /accepteula /SuppressReboot
If your servers don't have internet access, you can use the offline flag from a machine which does have access to download a copy of the required install files.
So your flow would be as follows:
Prepare Cached Version of Installers
webpicmd /Offline /Products:MVC3Runtime /log:webpi.log /Path:"%~dp0wbpiCache"
Install from cache (copy folder structure to target machine)
webpicmd /install /Products:MVC3Runtime /log:webpi.log /accepteula /SuppressReboot /XML:"%~dp0wbpiCache"
You don't need to install MVC3 on a server.
Just copy the MVC DLLs along with your projects.

Resources