In this lab, we will be installing the required development components and verifying that the solution builds and is able to be pushed to Azure DevOps.
- An active Azure subscription
Azure Portal - An active Azure DevOps account.
Sign up for Visual Studio Team Services
- Install Visual Studio 2017
Select ASP.NET and web development and Azure development tools on the installer. - Install Azure Power Shell
-
Open Visual Studio 2017
-
Make sure GIT is the current source control plugin (under Tools -> Options -> Source Control -> Plug-in Selection)
-
Go to File -> New -> Project... and create a new ASP.NET Core Web Application
- Name: DevOpsHOL
- Location: where ever you put project source
- Create Directory for solution: Checked
- Create new Git repository: Checked
- Click OK
- On the next dialog, choose Web Application (Model-View-Controller) as the application type, No Authentication
- Configure for https: UnChecked (unless you are up for the challenge)
- Click OK
- Name: DevOpsHOL
-
Build and run the solution to make sure everything is OK to this point.
- Debug -> Start Debugging (F5)
- If application doesn't start the first time, just run again.
- Do a quick smoke test to verify that the solution built and runs correctly.
- Close browser and stop debugging
- Debug -> Start Debugging (F5)
-
Choose File -> New -> Project... and add a MSTest Test Project (.NET Core) project, to the solution not the .NET Framework unit test project.
- Name: DevOpsHOL.Tests
- Solution: Add to solution
- Name: DevOpsHOL.Tests
-
Rename UnitTest.cs to HomeControllerTest.cs and replace the file contents with the content in the details section below.
Click here to expand the sample unit test code
[TestClass] public class HomeControllerTest { [TestMethod] public void Index() { // Arrange HomeController controller = new HomeController(); // Act ViewResult result = controller.Index() as ViewResult; // Assert Assert.IsNotNull(result); } [TestMethod] public void About() { // Arrange HomeController controller = new HomeController(); // Act ViewResult result = controller.About() as ViewResult; // Assert Assert.IsNotNull(result); Assert.AreEqual("Your application description page.", result.ViewData["Message"]); } [TestMethod] public void Contact() { // Arrange HomeController controller = new HomeController(); // Act ViewResult result = controller.Contact() as ViewResult; // Assert Assert.IsNotNull(result); } }
NOTE: This source is also available here: HomeControllerTest.cs
-
Add the "DevOpsHOL" as a reference to the DevOpsHOL.Tests project. Tip: Use quick refactoring.
-
Add references to Microsoft.AspNetCore.Mvc.Abstractions and Microsoft.AspNetCore.Mvc.ViewFeatures as well. Use the NuGet package manager to add these libraries to the project.
-
Build, run unit tests and run the solution to make sure everything is OK to this point.
- Test -> Run -> All Tests (Ctrl+R,A)
- Debug -> Start Debugging (F5)
- Do another quick smoke test to verify that the solution built and runs correctly.
- Close browser and stop debugging
- Test -> Run -> All Tests (Ctrl+R,A)
-
Add solution to VSTS project (Team Explorer -> Sync -> Publish Git Repo)
- Push to Visual Studio Team Services
- Repository name: DevOpsHOL
- Publish repository will create a project in VSTS (NOTE: if you have multiple VSTS accounts, make sure this is published to the correct Team Services Domain).
- Push to Visual Studio Team Services
-
Create the first commit for your project (Team Explorer -> Changes -> Commit All and Push). NOTE: This could be automatically staged so choose Commit Staged and Push.
-
Log in to VSTS with browser and verify that DevOpsHOL project was created and source code is uploaded.