Categories
.Net ASP.NET ASP.NET MVC AWS CI Cloud

.NET Build Server using Visual Studio Community 2017

In a previous post, I wrote about building a .NET continuous integration server using Windows Server 2016, Jenkins, and Build tools. For this setup, I avoided installing any Visual Studio software. In my opinion, it was a simple process to get everything installed and building correctly. Now that Visual Studio 2017 has been released, I want to setup a build server using the community edition. Here are the 7 steps I took to get a .NET build server using Visual Studio 2017 Community edition, Jenkins, Git, running on Windows Server 2016.

1. Launch a new Windows Server 2016 instance. I’m currently investing on learning AWS so I’ll use it as my cloud provider. Feel free to use Azure, Google Cloud or your own server.

2. Download and install Visual Studio 2017 Community edition. For this tutorial, I selected ASP.NET and web development option during the installation.

3. Download and install Jenkins. I selected version 2.46.1 for this tutorial. After installing Jenkins, you have the option to install recommended plugins or select them one by one. For this tutorial, I went with the option to installed recommended plugins.

4. Download and install Git. If you have a different source control tool, go ahead and install it. After installing Git, I went to the Global Tool Configuration section and updated the path to C:\Program Files\Git\bin\git.exe.

5. Install MSBuild plugin. Go to Manage Jenkins section and select plugins. From the available tab, find MSBuild and install it. I also updated the path in the Jenkins settings to C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\msbuild.exe.

6. Create a new Jenkins job. I used the free style option. For the settings I use Git as my source control tool. Since I’m building a .NET solution, I selected the build action that uses MSBuild and give it the solution or project name.

7. Trigger a new build. If all of the steps above were done correctly, you should have a successful build.

Installing Visual Studio Community edition makes it easier to have a build server setup. After installing it, you get the .NET framework needed plus the MSBuild executable. In my previous setup, I had to install more software. Build Tools 2015, .NET framework 4.5.2, 4.6.2. Hopefully this post helps you setup a reliable build server for your .NET applications.

Categories
.Net ASP.NET ASP.NET MVC AWS CI

5 Easy Steps to Setup a .Net Build Server on Windows 2016

winsrv2016

.NET developers have the luxury of using Visual Studio to write code. In my opinion, Visual Studio is one of best IDE in the market today. When you build your applications inside Visual Studio, you are using MsBuild to compile your code.

In the past, setting up a .NET build server without installing Visual Studio was challenging. Now that Microsoft is releasing more software as open source  software, setting up a .NET build server can be accomplish with no issues.

In this post, I want to share the steps I took to setup a .Net continuous integration server running on Windows 2016.

First, launch a new instance with Windows 2016. I’m using AWS but any cloud provider would work as well.

After launching the new Windows 2016 server, it is time to install the necessary software to create our build server.

  1. Install Microsoft .NET Framework 4.5.2 Developer Pack.
  2. Install Microsoft .NET Framework 4.6.2 Developer Pack.
  3. Install Microsoft Build Tools 2015.
  4. Install Jenkins 2.19.3.
  5. Copy files from developers’ machine located at C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\WebApplications to the same exact location on the new Windows 2016 server.

So far I have only tested this build server with a MVC website targeting .NET framework 4.5.2. Let me know if you run into any issues with this setup.

I hope to test different apps and also add support for .NET Core.

If you are using AWS, you can launch the same instance I have created by searching for “Jenkins Build Server 2.19.3”.

Categories
ASP.NET C# General

Getting started with RazorEngine

razor engine

RazorEngine is an open source templating engine based on Microsoft’s parsing engine. You can use Razor syntax to build dynamic templates. In a project that I’m working on, I’m using it to build an email based on data retrieved from different sources. Let me show you how to start using RazorEngine in your project.

Create a new console application using visual studio. Now install RazorEngine using nuget (Install-Package RazorEngine). After installing RazorEngine, you will see 2 packages in your packages.config, Microsoft.AspNet.Razor and RazorEngine.

Now create a strongly typed view.

emailTemplate

Make sure you save the file as a c# view (extension .chtml). As you can see from the above image, we are using the ConsumableData model which will hold the data for us.

With the template in place, we can add code in our Program.cs file to gather our ConsumableData by setting CustomerName to Raymond.

var data = new ConsumableData { CustomerName = “Raymond” };

With our data in place, it is time to use RazorEngine and compile our template.

var template = File.ReadAllText(“pathToTemplate”);
var email = RazorEngine.Engine.Razor.RunCompile(template, “templateKey”, typeof(ConsumableData), data, null);

After calling RazorEngine’s RunCompile method, we will have our email ready to be send.

As you can see, you can use RazorEngine to build dynamic templates. If you have used Asp.Net Mvc before, the above code should be familiar to you.

Take it for a spin and let me know what you think.

Categories
ASP.NET C# code General Git Tips

Show me your progress with your commits

Git Commit

I’m currently working in a new application. It’s an ASP.NET MVC site written with C#. We are using the following technologies: Windows Communication Foundation, Knockout, Bootstrap, PostgreSQL, and Git.

I’m working on a new feature that will require me to make changes to the UI, javascript files, add new database tables, add service methods, add unit and integration tests. In other words, I have to modify all layers in our application.

To accomplish this task, I decided to try something different. I want to show my progress with my git commits. I want to complete small tasks and then commit my changes. For this specific task, I started writing a falling integration test. This failing test forced me to create the new database tables needed. After creating the tables, I ran the tests again and this time everything was back to green. At this point, I’m ready to commit these changes. This commit is the beginning of my work and it gets me closest to the final goal. I go ahead and commit this change.

commitTableCreation

After adding the database tables, sql scripts to generate them, and some unit tests, I’m ready to start adding service methods, data contracts, etc. For this task, I follow the same technique as above. My unit tests pass and I have not broken the build so it is time for another commit. With this second commit, I’m feeling productive. I have accomplished something. I can show my progress to my boss or team members with these small commits.

On the other hand, working for a long time without committing your changes, makes me nervous. What would happen if your hard drive fails? It happens all the time. I think we all have experienced losing our work. Many times it was something other than a hardware failure. It was a human error. For example, we deleted some files that were not in source control by mistake.

That’s why I like to commit often. As long as my project builds and my unit tests pass, I’m going to commit my small changes. I know that these commits don’t fulfill a complete feature, but they take me a step closer to my finish line.

After a few commits, I have accomplished enough back-end code that I can concentrate on the UI. Here is the initial version of the UI:

ContractSurvey

It is not perfect. I know that changes are inevitable. I would say that right now I have completed 80% of the task needed to bring this work to completion. I have 20% more to go and I can see the finish line. Seeing the finish line motivates me to do my best and finish strong.

I urge developers to commit small changes and commit often. Remember that these small changes will help you accomplish your goals sooner rather than later.

Categories
.Net ASP.NET open source

What is the future of Microsoft’s Codeplex?

codeplex

Codeplex is Microsoft’s hosting site where you can create and collaborate on open source software. It is very similar to Github. You can create new projects, host your code, collaborate with other developers, download source code, report bugs, etc.

Last November, Microsoft announced that .NET 2015, ASP.NET 5, and other components will be developed and released as open source. Microsoft has setup the following projects in Github:

When I read Scott Hanselman’s blog posts related to the above announcement, I asked myself why those projects were not hosted at Codeplex. In my opinion, Codeplex is very popular within the Microsoft ecosystem. However, Github is the place where you host your open source project. Github is not tied to any operating sytem. It is very popular in the open source community.

I also read the blog posts in the Codeplex site and the last post was dated 2 years ago. Is Microsoft abandoning Codeplex? Are they concentrating their resources on other projects like Azure.

Let me know if you agree with me.

Thanks.

 

 

Categories
.Net ASP.NET C# open source Xamarin

All you need is C# to conquer the world

csharp c#

C# is an object-oriented programming language created by Microsoft. Wikipedia describes the language as “simple, modern, general-purpose, object-oriented programming language.” With the language, you can create many types of applications, web sites, desktop applications, mobile applications, web services, and many more.

If you know C#, then you can conquer the world. Yes, you read it correctly. You can conquer the world of software development with your knowledge of this programming language. You are only restricted by your imagination.

Here are the 3 reasons why I think C# is the number one programing language to conquer the world: mobile development, web applications, and open source initiatives.

Mobile Development

No one can deny that mobile applications are dominating our time and resources. Recent studies have found that the average user spends more time browsing thru mobile devices compared with desktop browsers. With these demand of mobile applications, businesses are pressured to keep up with this trend. Now they need to provide apps for the two major mobile ecosystems, Apple  and Google.

There are many choices to develop mobile applications, native, HTML, and C# with Xamarin. Nat Friedman and Miguel de Icaza created Xamarin to solve the problem of dealing with different code bases. If you want to write native applications for Android, you will have to write it in Java. If you want to write native applications for iOS, you will have to write it in objective-c. With Xamarin, you are able to share code across iOS, Android and Windows platform.

With your knowledge of C#, you write code once and Xamarin compiles your code for the intended platform.

Web Applications

There are many web sites developed to run under the .Net Framework. These sites still need to be managed and enhanced. Businesses have invested millions of dollars in their ASP.net sites and there is a need to keep these sites working correctly. If you know C# with experience in the ASP.NET web application framework, I assured you that there will be enough jobs for the years to come.

So who is using this framework? Some of the companies using ASP.NET are: US Airways, Bing, Msnbc, Kelley Blue Book, 3M and many others.

Open Source Initiatives

In November 2014, Microsoft announced in New York that many components that are part of the .NET framework are released in github as open source. See Scott Hanselman’s blog for a complete listing of projects and initiatives taken by Microsoft to make ASP.NET 5 cross platform. Along with these changes, Visual Studio Community is now available for students and open source developers. There is also a new .NET Core CLR for Linux, Mac, and Linux. If you want to see the changes, go to the github dotnet page. I believe these changes by Microsoft allows for more innovation. And with innovation, we will see new products and also improvement to the existing .NET framework.

Summary

I believe C# is an excellent programming language to conquere the world of software development. There are sites developed in the ASP.NET web framework that still need maintenance and enhancement. With the recent rise of mobile development, your C# skills will allow you to write cross-platform apps with Xamarin. The open source movement by Microsoft has taken a major change for C# developers. It will allow you to write cross platform on any OS.

Categories
.Net ASP.NET C#

Book giveaway – Professional ASP.NET 2.0 Security, Membership, and Role Management

Pro ASP.NET 2.0 Security

I’m giving away a book written by Stefan Schackow titled Professional ASP.NET 2.0 Security, Membership, and Role Management.  I no longer used this book and want to help other software developers using ASP.NET 2.0. To have a chance to win this book, write a comment below stating how you are helping others. Let me know how you are helping the next generation of software developers / engineers. You probably speak at conferences or teach programming in your community.

This offer is only available to people that live in the United States. I will choose a winner on Christmas day.

Categories
ASP.NET Continuous Delivery General

Frustrated Driven Development

Frustrated Driven Development

I want to share a story about FDD or Frustrated Driven Development. A few years back, I worked in a very large asp.Net web site and the deployments were done manually. As you can imagine the chaos and errors caused by manual deployments. Sometimes we forgot to include all required steps to deploy the application. The instructions to our IT department will look like:

1. Create a back up copy of the entire site.
2. Delete all the files except the web.config file.
3. Copy the folder contents from this location d:\deployments\eStoreApp\05-20-2008\production into the production folder.
4. Open up the web.config file from production and update the following app settings:
a. Update emailAddress value from oldEmail@test.com to newEmail@test.com.

These instructions were very difficult to follow by our IT department and many times we encounter issues because one of the steps required to deploy the site was never performed. IT will blame engineers and engineers will blame IT. I guess both IT and engineers were used to this process and the frustration level was low. It was so painful that no one wanted to change or improve this process.

However, we got a new team member in our IT department. At the beginning, Bob followed the deployments instructions but he started questioning this process. Bob was frustrated and started talking with his manager. Bob said, “there must be a better way to deploy asp.net sites”. He gather data and found a product by red gate called deployment manager.

Bob approached me and said, “I don’t want to do manual deployments anymore. Can you help me test this new deployment tool from Red Gate?” I replied, “sure, what do you need from me?”. Bob said, “I just need a nuget package”.

Within a few weeks, we installed deployment manager in our different environments (QA, Staging, and Production) and both teams IT and engineers were happy and using this tool to automate our deployments.

Hopefully this story encourages other teams to use Frustrated Driven Development to identify what is causing pain and frustration in your team and using that energy to solve or improve those processes.

Categories
.Net ASP.NET Beginners

How I learned .Net

I graduated from Southern Methodist University in 2001 with a bachelors degree in Management Information Systems. During my studies, I took classes in HTML, Javascript, Visual Basic 6 and Java. I interviewed with different companies but was unable to secure a full-time job in IT. So I decided to help my parents with their small furniture store in Dallas, TX.

While working at the furniture store, I learned so much about running a business. I learned about marketing, sales, accounting, managing people, and of course about IT. However, my desire was to work as a software developer. So I decided to learn .Net framework and specifically asp.net.

At the beginning I read many articles online about this new framework created by microsoft. .Net framework was the buzz word and I knew I had to learn it to secure a job as a software developer.

It was time to take action and start writing code. The online articles helped me a lot to understand the basics but I needed a mentor, a guide to write my first .net application. To accomplish that task, I bought this book:

Beginning ASP.NET 1.1 with Visual C# .NET 2003 by Wrox.

With the help of this book, I was able to setup my development environment and create my first asp.net site for the furniture store.

I highly recommend the books by Wrox specially the beginning series because they walk you step by step in learning a new programming language or framework.

I hope this article inspires other developers to start learning and creating projects.