Banner Image Banner Image

Articles

Get Insights And Updates On Tech Industry Trends

Home | Blog
.Net core development

Build Cross-Platform Web Apps Using .NET Core Development: Take Your Business To Next Level

September 7, 2020

History says the .Net framework worked only on windows platform which released in 2002. Later developers tried to bring the .Net code on mobile devices, Linux and mac-OS but weren’t working on applications. They were managing two separate applications to have cross-platform web apps compatibility. Therefore, they decided to choose .Net Core Development which can target any platform without a change in code. In short, it follows write once and run anywhere.

 “Write once, run anywhere” is a .Net core Development mantra which adds favor to your web apps. It’s an open-source development platform founded in 2014 and used for developing cross-platform web apps. The .Net core development supports four cross-platform scenarios like command-line apps, libraries, ASP.Net core web apps and other web APIs.

One of the reasons to use .Net core is it can use multiple times. It comes with a rich-featured framework and offers speedy performance web apps. The element ASP.Net offers to build an exact web application based on your needs.

Have An Awesome Idea For Your .NET Core Development?

Check below .Net Schedule

.Net Schedule

Here, in this blog, we’ll learn how to create simple .Net core console application which runs on multiple Operating systems. To begin with, this demo, make sure you have the following things installed on your system.

  • Visual Studio 2017 edition
  • .Net core 2 SDK

What is the .Net Core Application Deployment Options?

.Net Core applications can deploy using two options such as Framework Dependent Applications and Self-Contained Applications. We’ll find a couple of difference between the two.

Framework Dependent Applications

  • It needs .Net core framework to be installed on machine.
  • It can run on any Operating System without any modification.

Self-Contained Applications

  • It needs .Net core framework to be installed on machine.
  • It can run on any Operating System without any modification.

Now, if you’re clear with the above two models, then let’s dive in to understand how to run a .Net core app for multiple operating systems.

Create two simple .Net core console app and run on Windows and macOS. Use Visual Studio 2017 to create the applications. Another way is to generate .Net core applications using different IDEs and with the command line. Select the best tool or IDE that you think you’re more comfortable with.

If you choose the first option, i.e. Framework dependent application, then use the following steps:

  • Open Visual Studio
  • Click on File> New Project and choose .Net Core.
  • Choose Console App project type and create it.
  • Now, navigate towards program.cs. and write ‘Hello’ to console
  • Add Console.ReadLine(); to keep console window open and run the app

But if you choose Self-contained App then you need to add extra step then we have used in the above model. Check how it works:

  • Open Visual Studio
  • Click on File> New Project and choose .Net Core.
  • Choose Console App project type and create it.
  • Now, navigate towards program.cs. and write ‘Hello’ to console
  • Add Console.ReadLine(); to keep console window open and run the app
  • Now, Right-click on the project file and click on edit project options (This will let us know that we have created file using the self-contained app).

Publish App to Run on Windows platform

If you’re using framework dependent use previous steps as we did with windows. But you’re using Self-contained option then you need to add an extra step to it.

  • Open Visual Studio
  • Right-click on project file of a self-contained app, click on Edit project
  • Add a new runtime identifier and save it
  • Right-click on project and click Publish
  • In publish a preview, click on setting link and select Target Runtime
  • Change the target location to another folder and click on Save
  • Now, click on Publish

Publish App to run on MacOS Platform

After you publish App now, it’s time to run the application. Follow the below steps if you’ve used a framework dependent model.

  • Open Windows Explorer
  • Navigate to the folder that contains the publish results
  • On the navigation bar, type cmd before the path and click enter.
  • After the command prompt opened, now type ‘dotnet FrameworkDevelopmentApp.dll.
  • That’s it, and you have done. You’ll see Hello in the command window.

Now let’s try the self-contained app to run the application. Follow the below steps to execute in the best way.

  • Open Windows Explorer
  • Navigate to the folder that contains the publish results using the self-contained app
  • Doble clicks on SelfContainedApp.exe.

Run the app, and you’ll see the word Hello in a command window.

Looking To Hire .NET Core Developer For Your Business?

Run the App on Windows

After you publish App now, it’s time to run the application. Follow the below steps if you’ve used a framework dependent model.

  • Open Windows Explorer
  • Navigate to the folder that contains the publish results
  • On the navigation bar, type cmd before the path and click enter.
  • After the command prompt opened, now type ‘dotnet FrameworkDevelopmentApp.dll.
  • That’s it, and you have done. You’ll see Hello in the command window.

Now let’s try the self-contained app to run the application. Follow the below steps to execute in the best way.

  • Open Windows Explorer
  • Navigate to the folder that contains the publish results using the self-contained app
  • Doble clicks on SelfContainedApp.exe.

Run the app, and you’ll see the word Hello in a command window.

Run the App on macOS

If you have decided to use macOS, then copy the published results of the framework dependent and self-contained app. Follow the steps and run the app through a framework dependent model.

  • Install the .Net Core. We don’t need to install the SDK as it only need a runtime.
  • Open terminal window
  • Now, navigate to the folder which contains framework dependent app files
  • Now type dotnet FrameworkDependentApp.dll and click enter.
  • Run the app, and it will show Hello as output.

Run the app using Self-contained app

To run self-contained apps, we need to have permission to run the application. Follow the steps to run the app using this model on macOS.

  • Open terminal window
  • Navigate to the folder which contains self-contained application files
  • Type sudo chmod +x selfcontainedapp and click enter.
  • Type in the password in your domain account. Hit enter and grant access to run.
  • Now type Open Self-contained app and again hit enter.

The window will display word Hello by opening a new terminal window.

Transform Your Idea By Hiring Our Expert .NET Core Developers!

Wrap up

The above scenario can help to build cross-platform web apps using a simple framework. One of the main advantages of using ASP.Net Core Development Environment is it’s used to run on multiple platforms and is very simple to execute.

If you’re looking to make your libraries multi-platform, then Hire ASP.Net Core Developer from Techcronus who is providing modern-day services since 2010. Get an expert team of ASP.NET core developers who are ready to transform your business using multiple platforms. Connect with us to gain discuss your project.

Tags .NET Core Development, asp.net core development environment, Cross-Platform Web Apps, Hire ASP.NET Core Developer

By TechcronusAdmin

Techcronus is a worldwide supplier of Enterprise Business Solutions and Custom Software Development Services, with locations in the USA, Australia, and India. It has accomplished the successful delivery of over 800 projects to start-ups, SMBs, and well-known brands, such as Starbucks, Unilever, and IKEA. The firm's areas of expertise include Microsoft Dynamics 365 ERP/CRM solutions, Web Development, Business Applications Management (.NET and DevOps), Mobile Development (Native, Hybrid, Blockchain), Staff Augmentation, Product Development & Support, and UI Design and UX.

author
Written by
Ketul Sheth
Techcronus is a worldwide supplier of Enterprise Business Solutions and Custom Software Development Services, with locations in the USA, Australia, and India. It has accomplished the successful delivery of over 800 projects to start-ups, SMBs, and well-known brands, such as Starbucks, Unilever, and IKEA. The firm's areas of expertise include Microsoft Dynamics 365 ERP/CRM solutions, Web Development, Business Applications Management (.NET and DevOps), Mobile Development (Native, Hybrid, Blockchain), Staff Augmentation, Product Development & Support, and UI Design and UX.

You May Also Like

Dynamics GP
Ruby on Rails
Node.js Development

Get a free access of our exclusive IT research and tech articles

Get a free excess of our exclusive research and tech strategies to level up your knowledge about the digital realm