Running .net core on linux standalone - asp.net-web-api

I have started to work on a web service (web api) with .net core and visual studio 15.
My goal is to develop the service on windows and then deploy it on an offline linux pc (The only way to put files on the linux pc is with with an usb flash drive).
Im having trouble with finding documentations or guides on how to accomplish this. Most of the info out there is talking about azure and remote virtual servers which Is irrelevant.
Any information about how I can disturbute to linux and install the .net framework on a standalone linux will be very helpful

you can read about how to install .NET Core on Linux on this pages:
https://get.asp.net/OtherDownloads
https://docs.asp.net/en/latest/getting-started/installing-on-linux.html
To deploy an app to Linux I usually use a source code management like Git (push to Git from windows and pull from Git on Linux).
FTP to the Linux machine could be another option, creating an install package or just use a USB flash drive

I just answered a similar question here. Basically you need to publish your application with the
dnu publish -o ./deploy
command. It will allow you to package your application along with the required packages for distribution.
Using this should allow you to drop that output folder on any machine with .NET Core. You will be able to run your web from the output path without downloading packages from NuGet.

Related

How to run normal windows .exe in raspberry PI running Windows IOT core

I am very much new to windows core platform.
i have developed a console application in my normal windows 10 host machine using visual studio 2015 and it is working like a champ in local machine using intel(I5/I7) Processors.
Now i have to move my application to PI running windows IOT core. i did xcopy of my files and trying to run using power shell of my windows host machine but thing is.. i could not able to run my application and getting below error message.
why my application is not running in PI? In fact my application is compiled for X86 platforms for intel processors. is this the really cause?? if so how do i compile my source code to target for ARM processors. please let me know the workaround. thanks in advance.
That doesn't look like an architecture mismatch, it looks like a .NET Framework mismatch. (Your code must be AnyCPU, because none of the other options would run both on Intel and also on ARM, and clearly your code is starting to run)
The exception occurs inside log4net, one of the libraries you use. You will have to find a version of log4net that works on that .NET Framework version, or remove that library and find a different way to generate logs.
Windows IoT Core supports UWP and non-UWP app. IoT Core is a UWP centric OS and UWP apps are its primary app type.Universal Windows Platform (UWP) is a common app platform across all version of Windows 10, including Windows 10 IoT Core.
In addition to the traditional UI apps, IoT Core has added a new UWP app type called "Background Applications". These applications do not have a UI component, but instead have a class that implements the "IBackgroundTask" interface.
IoT Core supports certain traditional Win32 app types such as Win32 Console Apps,but only C++ is supported for developing Win32 apps on IoT Core.
If you open powershell and CD into the solution project folder
To compile your code for raspberry pi, you need to compile it using win-arm as target
You can issue one of the commands:
dotnet publish -c Debug -r win-arm
dotnet publish -c Release -r win-arm
It will then compile it into the bin folder relative to the publish profile you have chosen
'..\bin\Debug\netcoreapp2.0\win-arm\publish'
Copy all the content of the publish folder into a directory of choice on the raspberry pi.
This will be able to run a simple .NET Core console app on a raspberry pi running Windows IoT Core

How to host .NET Core webapp in MacBook Pro using apache?

I have created a simple .NET Core webapplication in mac using Visual studio for mac. Now want to test the application by hosting it locally.
Is it possible to host the application in mac? If yes, please share me the steps or any useful links to host the appliation using Nginx or Apache http in mac.
For Windows, I have used Local IIS to host and test the application in local server.
Assuming you have the appropriate SDK installed, its as simple as calling dotnet run from your source directory

How to Deploy a Windows Service using Visual Studio 2017 Community

Working with VS2017 Community I have written a service that works on my local machine. I followed the instruction here:
https://learn.microsoft.com/en-us/dotnet/framework/windows-services/walkthrough-creating-a-windows-service-application-in-the-component-designer
and installed it successfully using Installutil.exe (as per instructions in above link). All good.
I now want to deploy that across six servers in our organisation. In Microsoft's documentation about installing services (https://learn.microsoft.com/en-us/dotnet/framework/windows-services/how-to-install-and-uninstall-services) it says:
If you’re a developer who wants to release a Windows Service that users can install and uninstall you should use InstallShield
and links to a page that applies to VS2012 (can't post any more links as my reputation<10)
I have downloaded and installed the "Microsoft Visual Studio 2017 Installer Projects" package, which allows me to create a Setup Project. When I run it, it installs the project output correctly (i.e. copies the exe & dll files to the correct folder in Program Files) but does not create the service.
There's a detailed post about deploying services on this site (question 9021075) but when I follow those instructions I get a 1001 error on Install.
All the documentation I can find refers to earlier versions of VS or the previous Installer package, so I'm not even certain if I can do it with the software I am using.
So, with VS2017 Community using Microsoft Visual Studio 2017 Installer Projects, how to I create a stand-alone Installer to deploy a service that works correctly when installed locally using InstallUtil?
Or can I use InstallUtil on the target machines? I think I'd need to install Visual Studio on them for that, which I'd prefer not to. Is there a quicker way?
I only have 6 servers to install this on, so even some manual work-around might do.
Thank you for the responses. I now have a solution. I found InstallUtil on the Target Server (in my case it was in C:\Windows\Microsoft.NET\Framework64\v4.0.30319 but search will find it). I copied and added that to my project as content so when I now deploy it, I have InstallUtil in the same folder as my EXE.
To install, I run CMD as admin, cd to project folder and issue command:
installutil.exe myService.exe
This is a one-off task. Once the service is working, to update it I just need to stop it, upload the new myService.exe (& any DLLs) to overwrite the old ones and restart it again.
Further information about settings you're using for the serviceProcessInstaller1 and serviceInstaller1 files will be needed to debug this issue, as the 1001 error raised by the installer is a generic error.
An alternative way of doing this is to use Topshelf, which is a framework for hosting services written using the .NET framework. It simplifies the creation of services, allowing developers to create a simple console application that can be installed as a service using Topshelf. The reason for this is simple: It is far easier to debug a console application than a service. And once the application is tested and ready for production, Topshelf makes it easy to install the application as a service.
Alternatively, you could use InstallUtil.exe. It is part of the .NET Framework, so no need to install Visual Studio.

Windows universal app Rest API Raspberry Pi

I have Windows Core running on a Raspberry PI. How do I create a rest API in a Windows universal app to run on it? I want to be able send remote commands to the Raspberry PI from a mobile device. I did several search and couldn't find much information. Thanks.
As noted here there's a Restup open source project for this
and NuGet package for it
There's also some experimental (ie fun side project) from Damian on the ASP.NET team about hosting DNX (the host process for your ASP.NET Core apps) located here but that will need some updating to the latest bits.

How to development in Visual Studio and then deploy apps to Linux machine

How to develop app in Visual Studio and then deploy apps to Linux machine (OS - Ubuntu, web server - Nginx). Can any explain the steps, it will be a great help
I would say that there are three ways how you can develop apps for Linux using mono.
First is using only Visual Studio for development and from time to time deploy your app to Linux to see potential issues. I personally use this scenario because it's simple and when you are not messing with MS specific stuff or yet fully unsupported things then you shouldn't have problems (at least I didn't so far). Disadvantage is that you will discover mono specific problems only during runtime on Linux machine.
Second approach is using Visual Studio with Mono Tools. I tested it when it was in beta and it was sometimes quite handy (you will move the phase of discovering mono specific problems to your dev environment, however you can still have some certain issues on Linux machine), but since this tool doesn't support debugging for now I don't use it personally.
Third approach is to use only MonoDevelop on Linux (since debugging is now supported only in Linux). With 2.2 release this IDE becomes really good and suitable for development however I have tested only console and basic ASP.NET MVC apps so I can't tell you if it's ready for bigger projects.
Deployment to Linux is quite easy - I just installed proftpd on Linux machine, configured it and copied project there from Windows machine.
If you are developing an application for Linux in C (as Nginx is) or C++, you need to develop on Linux.
There are many IDEs for Linux that you can use for this.
You can also try to run Visual Studio in Linux using Wine.
Use Mono on Windows and compile your apps with it , I guess Apache is only supported ... Disclaimer - I do not have personally experience with it ...

Resources