Deploy and start .NET service on multiple Windows Server 2012 - c#

I have a service written in C# that relies on features in .NET 4.5 that are not yet supported in any version of mono, so I have to use Windows servers. In other cases to deploy a network service I would just SCP a jar/tar/whatever over and then SSH over the deployment process, and that can be made a part of an sh script that can distribute to wherever. But because this is Windows, I don't have those tools and I'm at a bit of a loss as to how to deploy this to 20 (or more) different servers.
So I see that there is a publish process in MSVS 2012, but it seems to make use of Windows file shares or else I'm supposed to send it to a website of some kind(???) but it doesn't look like it has any way of starting it even if I could figure out how to get it there.
Is there some product that does this in Windows or would it be easier for me to just install an SSH server? I have remote desktop access, but would prefer not to have to deploy anything manually on them.
Thank you!

Try using Powershell with WMI. [This question] (https://superuser.com/questions/337810/how-can-i-remotely-install-or-uninstall-a-service-on-windows-server-2008-r2) discussed some approaches to install windows service remotely.

Related

In Azure Devops, how can I deploy an exe file to as server as part of release (or something similar)

A solution consists of...:
Web app
Console app ("jobserver", which pulls jobs and processes them)
All is C#, .Net Core 5.
I have continuous deployment set up, so new versions of the web app are deployed to Azure Web App automatically.
However, the console app, I cannot figure out a good way to deploy to a Windows server (or pull). Right now, I go to the server, stop the app if it is not doing anything (otherwise I wait a bit). Then I copy the files over and start it up again. All manually.
I can think of several complicated workarounds, but I am thinking there must be easier way.
What are some ways the deployment of exe file could be handled? How are others handling this?
Ps. The console app cannot run on Azure Web App or as WebJob or similar, because it has requirements that means it has to run on a "real" windows server.
You can use the PowerShell on Target machines or SSH tasks to run commands on a remote machine. Similarly, to copy files, you can use Windows Machine File Copy or Copy Files Over SSH to copy your .exe to the server.

Windows User Impersonation in .NET Core on Linux?

I'm writing a .NET Core application in C# that will run on a Linux server, but I need to impersonate a Windows user in order to access some remote resources on a Windows Server. I have credentials to authenticate there, but all the implementations I see rely on the "Advanced Windows 32 Base API" (advapi32.dll), which is a shared Windows library not available on Linux.
How do I make this work?
I was able to get a solution by thinking outside the box a bit. I discovered that I could use SharpCifs.Core for CIFS access and the Microsoft PowerShell SDK to gain a remote PowerShell session, and get environment variables. I do wish that Microsoft would write some better cross-platform tooling.
Mono project has a kind of wrapper of several linux commands, one of them is seteuid (the linux command used for impersonation). It could be worth having a look to the NuGet package Mono.Posix.NETStandard. It seems is going to be revamped in the new .Net 5 version. I'm not sure if it can fit your needs...

How can I run an mvc app on windows server?

I'm really new at this, never hosted an app before, everything I've done so far has been locally.
I have a windows server 2008 sp1 running at work, with IIS installed. I access to it via remote desktop, and I need to be able to deploy my app, first locally on the server, so computers that can access it (through LAN) are able to use it.
Right now, if I create a folder and put some data in it, with an html file, and go to "localhost" in a browser, I can see the rendered html file.
The version installed is IIS 7.0, and my app is uses the MVC pattern, and .net framework 4.6.
If on my windows 10 PC I start my app (vs 2017) I can see it on my browser.
I want to be able to do what I do in my PC but on the server. How can I do this?
Update:
I tried Publishing the app through vs but that is on my windows pc and getting a lot of errors. What I know so far is that a guy from Networks gets the app by the developers and they publish it, but I don't know what kind of files does he need.
I followed tutorials but I just can't apply them.
As I said earlier, I have visual studio installed on my w10 PC, and tried publishing through that app to the ip where the server is, getting a lot of errors.
I don't know what to do, I'm really trying a lot of different things, but I don't even know how the app is supposed to look to be run in any way that is not how I run it in visual studio.
UPDATE:
I'm getting this error when I try to publish locally
Here is the Outline of what we need as per OPs requirement
In VS publish the App to a folder
Sort out the server prerequisites:
Turning Windows Feature On or Off for ASP.NET, ISAPI filters, ISAPI extensions, NET extensibility
Server should have .NetFramework installed
Copy the published folder to the Server
Configure IIS manager to add a new site and set physical path to published folder

Host ASP.NET MVC4 website in windows without VisualStudio or IIS installed in it

I have ASP.NET MVC4 published as a file system. I need to host it in a fresh windows machine which does not have either VisualStudio and IIS installed in it;
Ways I analysed:
Using WebDev.WebServer, it can be done; Link
Question:
1) Does WebDev.WebServer gets installed along with a VisualStudio installation?
2) If not , please tell how can I install WebDev.WebServer as a standalone application in a windows machine,
Note:
Based on the answer in this discussion, I tried, but couldn't succeed. Reason is I couldn't find gacutil.exe in a fresh windows 8 machine which doesn't have VS / IIS installed in it.
WebDev.WebServer is kind of superseded by IIS Express now, which is documented, much more configurable, supports IIS extensions and other stuff. You can say it's pretty portable and does not require privileged account (for the most part).
Introduction blog post, IIS Express Readme
I'd suggest trying IIS Express instead of WebDev.WebServer.

Execute C# code on Centos (Linux)?

I have simple C# console application developed in Visual Studio 2008, which writes information in MySQL database. Is it possible to run the application in my hosting environment (Cent OS, with local MySQL database)? I have only control panel or ftp access to my hosting space. The database is only accessible from local (from the hosting space).
I have read something about Mono/Monodevelop, but those need to be run on the Cent OS, right? I don't have access to install this or other staffs on the hosting environment.
Given what you've specified about the environment and your limitations, not you can't run it.
You will need to have Mono installed to run a .NET app on Linux. If you can't install it, you're probably out of luck.
You could check with your hosting provider to see if they have other options.
If your hosting provider allows it, has mono installed, and you've verified that your application runs under mono you may be able to invoke the program via a shell command from php.
<?php
$output = shell_exec('mono myprogram.exe');
echo "<pre>$output</pre>";
?>
If your host has mono installed, and you have the ability to execute arbitrary shell commands from PHP, then you can run it. Otherwise no. Do you have the source to the program? If so, I would just port the code to PHP (or whatever your host provides).

Categories