Who we are

We are the developers of Plastic SCM, a full version control stack (not a Git variant). We work on the strongest branching and merging you can find, and a core that doesn't cringe with huge binaries and repos. We also develop the GUIs, mergetools and everything needed to give you the full version control stack.

If you want to give it a try, download it from here.

We also code SemanticMerge, and the gmaster Git client.

.NET Beyond Windows

Monday, March 23, 2015 Josué Yeray 0 Comments

On November 2014 Microsoft announced their new strategy for the .NET future. The most important part of the announcement was the release of .NET Core 5 as a componentized framework that will be shipped via NuGet. The .NET Core CLR is open source, and supports Windows, Linux and Mac OS X. It's publicly available in GitHub.

Practical uses

.NET 2015 is a set of .NET releases that provides a cohesive experience and unifies the family of .NET technologies. Depending on the application type you want to create you now have two choices:

  • the full .NET Framework
  • the new .NET Core 5 framework

You will also notice in the diagram above that any technology that relies on .NET Core CLR as runtime could potentially be used with Mac OS X and Linux. The best examples of this are ASP.NET 5 and .NET Native.

To further assist developers on how to use .NET with other non-windows platforms, Microsoft created a new community within Microsoft called the OmniSharp organization. Thanks to their work developers are now able to develop ASP.NET 5 projects using popular editors, including:

  • Sublime Text 3
  • Atom
  • Emacs
  • Brackets
  • Vim
  • Command line

In this article we are going to explain how to create your first ASP.NET 5 app using the Sublime Text 3 editor. If you would like information on how to use another platform/editor then visit the OmniSharp website were you will find exact instructions.

Sublime Text 3, Mac OS X & .NET Core

In order to follow along with the information described in this article you will need to install the following software, but don't worry, we will guide you through the process:

  • Mac OS X 10.7 or later
  • ASP.NET vNext Command Line tools
  • Sublime Text 3 Beta
  • Package control for Sublime Text 3
  • Kulture plugin
  • OmniSharp plugin
  • Yeoman and yo generator for ASP.NET

Installing ASP.NET vNext Command Line Tools

In order to develop and run ASP.NET 5 apps you will need to install the ASP.NET tools on your Mac OS X using the Homebrew package manager for OS X:

To install Homebrew open a new terminal window and paste the ruby script displayed on the Homebrew web page. This will create the needed folders, download Homebrew from GitHub and prepare your system to use Homebrew.

Open a new terminal window and paste the above script in the homebrew web site:

After installing Homebrew you can use the same terminal window to download the ASP.NET 5 related repositories by executing the command:

brew tap aspnet/k

After downloading the ASP.NET 5 related repositories, you can install a stable version of KVM to your local environment by executing the command:

brew install kvm

If your system does not understand kvm then run this last command:

source kvm.sh

And you are ready to go for the next step!

Installing Sublime Text 3

To install the Sublime Text 3 beta on your Mac system, simply navigate to www.sublimetext.com and hover over the big blue download for OS X button. In the new pop up window select "Sublime Text 3 beta" which will send you to the download page were you can download the OS X version of Sublime Text 3:

Package control for Sublime Text 3

After you have installed Sublime text 3, you will need to setup the Package control so that you can install the necessary plugins. To do this, simply open Sublime Text 3 and press [CTRL + `] or the [View > Show Console menu] then paste the code the code below to setup all package controls and dependencies:

import urllib.request,os,hashlib; h = 'eb2297e1a458f27d836c04bb0cbaf282' + 'd0e7a3098092775ccb37ca9d6b2e4b7d'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)

After you have performed the install a restart may be required to ensure that all of the required dependencies are installed correctly.

Kulture & OmniSharp plugins

After installing Package control, adding plugins to Sublime Text is fairly easy. Simply go to Sublime Text 3 and open the command palette [Cmd + Shift + P] or [Tools > Command Palette menu].

Once the command palette is open, select the "Package Control: Install Package" option. The first time you perform this task you may notice a slight delay while Sublime loads all repositories. When the list appears, type Kulture in the search box and then select the Kulture plugin:

Repeat the search operation but this time type OmniSharp in the search box to install the OmniSharp plugin in Sublime Text 3.

Yeoman & yo generator for ASP.NET

Once the Kulture and OmniSharp plugins are installed, you are now ready to create a new project. If you were using Visual Studio you would simply go to the File menu and select the new project option. In OS X and Sublime the options to create an ASP.NET project are not available so to make this process easier, you need to use Yeoman and yo generator.

To use Yeoman and yo generator you will need to have Node.JS and npm already installed on your system. If you don't have Node.JS and npm installed, just visit www.nodejs.org and follow the instructions to install them.

Once Node.js and npm are installed you can install Yeoman by running the following npm command:

npm install –g yo

If you receive an error indicating that Administrator execution is required, simply use sudo and that should resolve the issue. Now repeat the same process to install the ASP.NET generator:

npm install –g generator-aspnet

Finally execute the following command to run the ASP.NET generator:

yo aspnet

You are now ready to start creating some C# ASP.NET 5 code using the Mac OS X and Sublime Text 3.

When you first start writing your code you will be asked to grant permission to send usage statistics to improve the tool. Once you have decided to collaborate or not you will be presented with a selection screen to create a new project:

For this article we are creating a Web application so you will need to select the web application option. The generator will then ask you for a project name and it will create all necessary folders and files. In this article, the name we are giving the project is NetCoreWebSample.

A little ASP.NET 5 sample

The scope of this article was to focus on installation of the software necessary to create an OS X + Sublime Text environment, to enable you to create your first ASP.NET 5 project using the Sublime Text 3 editor. Since the scope does not include detailed information about ASP.NET, we are going to demonstrate the capabilities of the software environment by creating a simple ASP.NET 5 project using Sublime Text 3 running on Mac OS X Mavericks. So let's get started.

With the ASP.NET web project created using the ASP.NET generator, you are now ready to add all files to the new Sublime project. To do this, open Sublime Text 3 and go to Project > Save Project as... and save your project file in the NetCoreWebSample folder:

Next, go to Project > Add folder to project and add the NetCoreWebSample folder to your project. You will now be able to view all your ASP.NET project files in Sublime and open them. As you can see, your C# code is colored and includes intellisense support:

To build your project you simply press the Cmd + B key combination. If you get an error stating that the kpm command is not found, you will need to upgrade the KVM installation by running the following command in a terminal window:

Source KVM.sh
KVM upgrade

While you are still in the terminal window, you will need to download all of the dependencies necessary to run your project. Take into account you will need to do this in your Project folder.

To do this, execute the following restore command to start downloading all dependencies stored in the project.json file in your project:

Kpm restore

Once all of the dependencies are downloaded, you can use the Kestrel web server to host the website by executing the following command:

k kestrel

After the Kestrel web server has started, you can navigate to your web site in localhost, using Safari and voila! You have developed an ASP.NET 5 app using Sublime Text 3 running on Mac OS X Mavericks:

Adding source code management with Plastic SCM

There is one more component that the development environment needs in order to make it complete and that is Source Code Management using Plastic SCM. To install Plastic SCM for Mac OS X, simply go to the Plastic SCM website and you will find the latest version for Mac OS X in the downloads section:

Download the package and install it.

If you receive a notification about your security settings not allowing you to install apps outside the app store, go to Settings > Security & privacy and click on the Install anyway button to continue with the installation (for a detailed guide click here).

Before starting any work with Plastic SCM we recommend that you go to more downloads page and download the Macplastic GUI. The GUI currently included with Plastic SCM installation is based on X11, but Macplastic was developed natively using Cocoa so it has a better look and feel as well as higher performance:

After installation and configuration is complete, you simply open Plastic SCM GUI to create a new workspace. For this example we will use the folder NetCoreWebSample that we created previously:

You will now be able to use the Plastic SCM transparent SCM technology to track your files automatically. So after you add them to source control, any change will be tracked. For files that have not yet been added to source control (pending), Plastic SCM will detect them and help you add them to source control by right clicking on the main tree root:

If you right click on the main tree root and select Checkin from the drop down, a new view will be launched on the right half of the showing you the changes that you will commit to the server. Clicking on the Checkin button will start syncing the changes to the server:

Refactoring .NET code with Sublime and Plastic SCM

You can now return to Sublime and begin editing some code. In this example, we edited the HomeController.cs file in the Controllers folder. We also renamed the Controllers folder to ASPNETControllers by right clicking on the folder name in the left panel folders tree and selecting the rename option. When the "New Name" box is displayed at the bottom of the editor, enter a new name and click enter to assign the new name to the selected folder:

If you return to the Plastic SCM Macplastic GUI you will find that all of our changes are automatically tracked. Now, any change you make in your code (edit, move, rename, delete, etc.) is automatically tracked. Everything is controlled so you can focus on actually creating some code. Plastic SCM will also recognize and track multiple changes like renaming of the Controllers folder and the edit of the HomeController controller file:

Conclusion

As you have read in this article, there is a .NET Future - Beyond Windows and it is here today.

Just as Xamarin allows you to write code in C# and create native apps for iOS, iPad, Mac, Android and Windows, with Microsoft embracing open source and third party development tools, you can take advantages of the powerful features of C# to develop web sites and web applications without needing Windows, even for development process.

Although this technology is still in its infancy, now is the time to begin exploring the powerful features of website development using ASP.NET 5 on the Mac OS X platform because by doing so you will be ready when this technology is ready for prime time.

Keep in mind that whatever your development environment is, Plastic SCM is there to keep your code secure. Whether you work on Mac or Windows, you can download the same suite of tools and have your code secure and controlled. For more information on Plastic SCM, visit our website.

0 comentarios: