{"id":1423,"date":"2016-02-24T09:16:12","date_gmt":"2016-02-24T14:16:12","guid":{"rendered":"http:\/\/codinggorilla.domemtech.com\/?p=1423"},"modified":"2016-03-07T07:14:20","modified_gmt":"2016-03-07T12:14:20","slug":"getting-c-working-on-friggin-linux","status":"publish","type":"post","link":"http:\/\/165.227.223.229\/index.php\/2016\/02\/24\/getting-c-working-on-friggin-linux\/","title":{"rendered":"Getting C# on Friggin&#8217; Linux Working"},"content":{"rendered":"<p>If you like C#, and want to program using it across all platforms&#8211;including Linux&#8211;it&#8217;s easy using the <a href=\"http:\/\/www.mono-project.com\/\" target=\"_blank\">Mono<\/a>\u00c2\u00a0runtime! The details of the Mono project I won&#8217;t go into detail here, but rather only show how to set up a &#8220;Hello world!&#8221; project that will build and run on Ubuntu. Note: <a href=\"http:\/\/www.monodevelop.com\/\" target=\"_blank\">MonoProject<\/a> is an IDE for Mono projects. I highly recommend you install that.<\/p>\n<p>Prerequisites:<\/p>\n<ul>\n<li><a href=\"https:\/\/www.virtualbox.org\/\" target=\"_blank\">VirtualBox<\/a>.<\/li>\n<li><a href=\"https:\/\/www.visualstudio.com\/\" target=\"_blank\">Microsoft Visual Studio 2015 Community Edition<\/a>.<\/li>\n<li>You will need to create a virtual machine with <a href=\"http:\/\/www.ubuntu.com\/\" target=\"_blank\">Ubuntu<\/a>.<\/li>\n<\/ul>\n<p>There are three options you can use to get the source project onto the virtual machine: (1) Use Visual Studio to create a Hello World program, then set up a mapped folder in VirtualBox that contains the project. (2) Use Visual Studio to create a Hello World program, then use Git to clone the repository onto the guest machine. If you&#8217;d like, you can skip this step, and use the example at\u00c2\u00a0<a href=\"https:\/\/bitbucket.org\/ken_domino\/hw\/overview\" target=\"_blank\">https:\/\/bitbucket.org\/ken_domino\/hw\/overview<\/a>. (3)\u00c2\u00a0Use MonoProject to create a Hello World program from scratch on Ubuntu.<\/p>\n<p>Method:<\/p>\n<ol>\n<li>In your Windows host machine, start Visual Studio.<\/li>\n<li>In Visual Studio:\n<ol>\n<li>Create a new C# console application within the mapped directory for the virtual machine.<\/li>\n<li>Add System.Console.WriteLine(&#8220;Hello world!&#8221;); to the main method.<\/li>\n<li>Compile and run to verify that it works.<\/li>\n<\/ol>\n<\/li>\n<li>Let&#8217;s set up Mono on the guest machine. In the virtual machine:\n<ol>\n<li>Open a Terminal.<\/li>\n<li><code>cd &lt;mapped-directory&gt;\/&lt;project-directory&gt;<\/code>\n<ol>\n<li>Make sure the directory is mapped and you see the new project.<\/li>\n<\/ol>\n<\/li>\n<li><code>sudo apt-key adv --keyserver hkp:\/\/keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF<\/code>\n<ol>\n<li>You are creating a\u00c2\u00a0package repository for Mono.<\/li>\n<li>These instructions are from the <a href=\"http:\/\/www.mono-project.com\/docs\/getting-started\/install\/linux\/\" target=\"_blank\">Mono Project install for Ubuntu<\/a>.<\/li>\n<\/ol>\n<\/li>\n<li><code>echo \"deb http:\/\/download.mono-project.com\/repo\/debian wheezy main\" | sudo tee \/etc\/apt\/sources.list.d\/mono-xamarin.list<\/code><\/li>\n<li><code>sudo apt-get update<\/code><\/li>\n<li><code>sudo apt-get install mono-complete<\/code><\/li>\n<\/ol>\n<\/li>\n<li>Let&#8217;s now build the Hello World program. Use one of the three methods I mentioned above. Then&#8230;\n<ol>\n<li><code>xbuild<\/code>\n<ol>\n<li>&#8220;<a href=\"http:\/\/www.mono-project.com\/docs\/tools+libraries\/tools\/xbuild\/\" target=\"_blank\">xbuild<\/a>&#8221; is Mono&#8217;s version of &#8220;<a href=\"https:\/\/en.wikipedia.org\/wiki\/MSBuild\" target=\"_blank\">msbuild<\/a>&#8220;.<\/li>\n<\/ol>\n<\/li>\n<li><code>mono bin\/Debug\/&lt;project-executable&gt;<\/code>\n<ol>\n<li>You should see the &#8220;Hello world!&#8221; in the terminal.<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<\/li>\n<li>Install the MonoDevelop application if you want to have an IDE for C# on Linux. It is similar to Xamarin Studio. You can then open the project in MonoDevelop.\n<ol>\n<li><code>sudo apt-get install monodevelop<\/code><\/li>\n<\/ol>\n<\/li>\n<li>Install the XSP4 server if you want to write ASP.NET projects.\n<ol>\n<li><code>sudo apt-get install mono-xsp4<\/code><\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<pre>dokku@kukku:\/vagrant\/hw$ which mono\r\n\/usr\/bin\/mono\r\ndokku@kukku:\/vagrant\/hw$ mono --version\r\nMono JIT compiler version 4.2.2 (Stable 4.2.2.30\/996df3c Mon Feb 15 17:30:30 UTC 2016)\r\nCopyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com\r\n\tTLS:           __thread\r\n\tSIGSEGV:       altstack\r\n\tNotifications: epoll\r\n\tArchitecture:  amd64\r\n\tDisabled:      none\r\n\tMisc:          softdebug \r\n\tLLVM:          supported, not enabled.\r\n\tGC:            sgen\r\ndokku@kukku:\/vagrant\/hw$ which mono\r\n\/usr\/bin\/mono\r\ndokku@kukku:\/vagrant\/hw$ mono --version\r\nMono JIT compiler version 4.2.2 (Stable 4.2.2.30\/996df3c Mon Feb 15 17:30:30 UTC 2016)\r\nCopyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com\r\n\tTLS:           __thread\r\n\tSIGSEGV:       altstack\r\n\tNotifications: epoll\r\n\tArchitecture:  amd64\r\n\tDisabled:      none\r\n\tMisc:          softdebug \r\n\tLLVM:          supported, not enabled.\r\n\tGC:            sgen\r\ndokku@kukku:\/vagrant\/hw$ xbuild \/target:Clean\r\nXBuild Engine Version 12.0\r\nMono, Version 4.2.2.0\r\nCopyright (C) 2005-2013 Various Mono authors\r\n\r\nBuild started 2\/24\/2016 9:11:49 AM.\r\n__________________________________________________\r\nProject \"\/vagrant\/hw\/hw.sln\" (Clean target(s)):\r\n\tTarget ValidateSolutionConfiguration:\r\n\t\tBuilding solution configuration \"Debug|Any CPU\".\r\n\tTarget Clean:\r\n\t\tProject \"\/vagrant\/hw\/hw.csproj\" (Clean target(s)):\r\n\/vagrant\/hw\/hw.csproj:  warning : Project has unknown ToolsVersion '14.0'. Using the default tools version '4.0' instead.\r\n\t\t\tTarget CoreClean:\r\n\t\t\t\tDeleting file '\/vagrant\/hw\/obj\/Debug\/.NETFramework,Version=v4.5.AssemblyAttribute.cs'\r\n\t\t\t\tDeleting file '\/vagrant\/hw\/bin\/Debug\/hw.exe.config'\r\n\t\t\t\tDeleting file '\/vagrant\/hw\/bin\/Debug\/hw.exe.mdb'\r\n\t\t\t\tDeleting file '\/vagrant\/hw\/bin\/Debug\/hw.exe'\r\n\t\t\t\tDeleting file '\/vagrant\/hw\/obj\/Debug\/hw.exe'\r\n\t\t\t\tDeleting file '\/vagrant\/hw\/obj\/Debug\/hw.exe.mdb'\r\n\t\t\t\tDeleting file '\/vagrant\/hw\/obj\/Debug\/hw.csproj.FilesWrittenAbsolute.txt'\r\n\t\tDone building project \"\/vagrant\/hw\/hw.csproj\".\r\nDone building project \"\/vagrant\/hw\/hw.sln\".\r\n\r\nBuild succeeded.\r\n\r\nWarnings:\r\n\r\n\/vagrant\/hw\/hw.sln (Clean) -&gt;\r\n(Clean target) -&gt;\r\n\/vagrant\/hw\/hw.csproj (Clean) -&gt;\r\n\r\n\t\/vagrant\/hw\/hw.csproj:  warning : Project has unknown ToolsVersion '14.0'. Using the default tools version '4.0' instead.\r\n\r\n\t 1 Warning(s)\r\n\t 0 Error(s)\r\n\r\nTime Elapsed 00:00:00.5173490\r\ndokku@kukku:\/vagrant\/hw$ ls -R\r\n.:\r\nApp.config  bin  hw.csproj  hw.sln  obj  Program.cs  Properties\r\n\r\n.\/bin:\r\nDebug\r\n\r\n.\/bin\/Debug:\r\nhw.pdb  hw.vshost.exe  hw.vshost.exe.config  hw.vshost.exe.manifest\r\n\r\n.\/obj:\r\nDebug\r\n\r\n.\/obj\/Debug:\r\nDesignTimeResolveAssemblyReferencesInput.cache  TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs  TempPE\r\nhw.csproj.FileListAbsolute.txt                  TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs\r\nhw.csprojResolveAssemblyReference.cache         TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs\r\n\r\n.\/obj\/Debug\/TempPE:\r\n\r\n.\/Properties:\r\nAssemblyInfo.cs\r\ndokku@kukku:\/vagrant\/hw$ xbuild \/target:Rebuild\r\nXBuild Engine Version 12.0\r\nMono, Version 4.2.2.0\r\nCopyright (C) 2005-2013 Various Mono authors\r\n\r\nBuild started 2\/24\/2016 9:12:19 AM.\r\n__________________________________________________\r\nProject \"\/vagrant\/hw\/hw.sln\" (Rebuild target(s)):\r\n\tTarget ValidateSolutionConfiguration:\r\n\t\tBuilding solution configuration \"Debug|Any CPU\".\r\n\tTarget Rebuild:\r\n\t\tProject \"\/vagrant\/hw\/hw.csproj\" (Rebuild target(s)):\r\n\/vagrant\/hw\/hw.csproj:  warning : Project has unknown ToolsVersion '14.0'. Using the default tools version '4.0' instead.\r\n\t\t\tTarget PrepareForBuild:\r\n\t\t\t\tConfiguration: Debug Platform: AnyCPU\r\n\t\t\tTarget GenerateSatelliteAssemblies:\r\n\t\t\tNo input files were specified for target GenerateSatelliteAssemblies, skipping.\r\n\t\t\tTarget CoreCompile:\r\n\t\t\t\tTool \/usr\/lib\/mono\/4.5\/mcs.exe execution started with arguments: \/noconfig \/debug:full \/debug+ \/optimize- \/out:obj\/Debug\/hw.exe Program.cs Properties\/AssemblyInfo.cs obj\/Debug\/.NETFramework,Version=v4.5.AssemblyAttribute.cs \/target:exe \/define:\"DEBUG;TRACE\" \/nostdlib \/platform:AnyCPU \/reference:\/usr\/lib\/mono\/4.5\/System.dll \/reference:\/usr\/lib\/mono\/4.5\/System.Xml.Linq.dll \/reference:\/usr\/lib\/mono\/4.5\/System.Data.DataSetExtensions.dll \/reference:\/usr\/lib\/mono\/4.5\/Microsoft.CSharp.dll \/reference:\/usr\/lib\/mono\/4.5\/System.Data.dll \/reference:\/usr\/lib\/mono\/4.5\/System.Net.Http.dll \/reference:\/usr\/lib\/mono\/4.5\/System.Xml.dll \/reference:\/usr\/lib\/mono\/4.5\/System.Core.dll \/reference:\/usr\/lib\/mono\/4.5\/mscorlib.dll \/warn:4\r\n\t\t\tTarget _CopyAppConfigFile:\r\n\t\t\t\tCopying file from '\/vagrant\/hw\/App.config' to '\/vagrant\/hw\/bin\/Debug\/hw.exe.config'\r\n\t\t\tTarget DeployOutputFiles:\r\n\t\t\t\tCopying file from '\/vagrant\/hw\/obj\/Debug\/hw.exe.mdb' to '\/vagrant\/hw\/bin\/Debug\/hw.exe.mdb'\r\n\t\t\t\tCopying file from '\/vagrant\/hw\/obj\/Debug\/hw.exe' to '\/vagrant\/hw\/bin\/Debug\/hw.exe'\r\n\t\tDone building project \"\/vagrant\/hw\/hw.csproj\".\r\nDone building project \"\/vagrant\/hw\/hw.sln\".\r\n\r\nBuild succeeded.\r\n\r\nWarnings:\r\n\r\n\/vagrant\/hw\/hw.sln (Rebuild) -&gt;\r\n(Rebuild target) -&gt;\r\n\/vagrant\/hw\/hw.csproj (Rebuild) -&gt;\r\n\r\n\t\/vagrant\/hw\/hw.csproj:  warning : Project has unknown ToolsVersion '14.0'. Using the default tools version '4.0' instead.\r\n\r\n\t 1 Warning(s)\r\n\t 0 Error(s)\r\n\r\nTime Elapsed 00:00:01.1014250\r\ndokku@kukku:\/vagrant\/hw$ ls -l bin\/Debug\/hw.exe\r\n-rwxrwxrwx 1 dokku dokku 4096 Feb 24 09:12 bin\/Debug\/hw.exe\r\ndokku@kukku:\/vagrant\/hw$ mono !$\r\nmono bin\/Debug\/hw.exe\r\nHello world!\r\ndokku@kukku:\/vagrant\/hw$ \r\n\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>For more information:<\/p>\n<ul>\n<li>VirtualBox -\u00c2\u00a0<a href=\"https:\/\/en.wikipedia.org\/wiki\/VirtualBox\" target=\"_blank\">Wikipedia<\/a><\/li>\n<li>Mono Project &#8211; <a href=\"https:\/\/en.wikipedia.org\/wiki\/Mono_(software)\" target=\"_blank\">Wikipedia<\/a><\/li>\n<li>Net Framework Core &#8211; <a href=\"https:\/\/en.wikipedia.org\/wiki\/.NET_Framework#.NET_Core\" target=\"_blank\">Wikipedia<\/a><\/li>\n<li>Visual Studio Community -\u00c2\u00a0<a href=\"https:\/\/en.wikipedia.org\/wiki\/Microsoft_Visual_Studio\" target=\"_blank\">Wikipedia<\/a><\/li>\n<li>MonoDevelop &#8211; <a href=\"https:\/\/en.wikipedia.org\/wiki\/MonoDevelop\" target=\"_blank\">Wikipedia<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you like C#, and want to program using it across all platforms&#8211;including Linux&#8211;it&#8217;s easy using the Mono\u00c2\u00a0runtime! The details of the Mono project I won&#8217;t go into detail here, but rather only show how to set up a &#8220;Hello world!&#8221; project that will build and run on Ubuntu. Note: MonoProject is an IDE for &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/165.227.223.229\/index.php\/2016\/02\/24\/getting-c-working-on-friggin-linux\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Getting C# on Friggin&#8217; Linux Working&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/posts\/1423"}],"collection":[{"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/comments?post=1423"}],"version-history":[{"count":0,"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/posts\/1423\/revisions"}],"wp:attachment":[{"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/media?parent=1423"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/categories?post=1423"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/tags?post=1423"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}