Next add a line / lines Debugger.Break(); in your code where you want the debugger to start. Now compile in debug mode clicking in Visual Studio menu: Build, Build Solution while the Configuration Manager is set to Debug.
After the application compiled successfully we can stop and start the service to ensure these modifications are run:
Right click the Visual Studio application and select more…, Run as administrator
Click Debug, Attach to Process in the Visual Studio menu.
This will open a dialog where you need to select the right process to debug. Check the Show processes from all users checkbox. Find your Service process and click Attach.
In Visual Studio it is really simple to add unit tests that are automatically run in your build script. Right click your solution to add a test project:
/// <summary> /// Test if flipcoins throws as many times as requested /// </summary> [TestMethod()] public void FlipCoinsTest1Times() { //Arrange int odd, even; int times = 1;
//Act CoinFlipper coinFlipper = new CoinFlipper(); coinFlipper.FlipCoins(times, out odd, out even); //Assert Assert.IsTrue(times == odd + even); }
Open Test explorer window
Right click a selection of tests and select “Run selected tests”.
When the tests are OK, we can check in the solution. Default the Build in Azure will run libraries with names containing *test*.
I was planning a migration for my solution from a build on my local machine to a build in Azure Devops. I want to use the Hosted VS2017 because then I do not have to worry about maintaining local Build servers.
When I added the solution to Azure and set up a build pipeline I encountered the following errors in the MSBuild log:
2019-01-10T10:11:49.9382855Z ##[error]Notepad\CrystalReportsViewer.cs(8,7): Error CS0246: The type or namespace name ‘CrystalDecisions’ could not be found (are you missing a using directive or an assembly reference?)
2019-01-10T10:11:49.9412999Z ##[error]Notepad\CrystalReport1.cs(153,53): Error CS0246: The type or namespace name ‘RequestContext’ could not be found (are you missing a using directive or an assembly reference?)
2019-01-10T10:11:49.9414407Z ##[error]Notepad\CrystalReportsViewer.cs(14,16): Error CS0246: The type or namespace name ‘ReportDocument’ could not be found (are you missing a using directive or an assembly reference?)
2019-01-10T10:11:49.9415960Z ##[error]Notepad\CrystalReport1.cs(19,35): Error CS0246: The type or namespace name ‘ReportClass’ could not be found (are you missing a using directive or an assembly reference?)
2019-01-10T10:11:49.9430403Z ##[error]Notepad\CrystalReport1.cs(24,32): Error CS0115: ‘CrystalReport1.ResourceName’: no suitable method found to override
2019-01-10T10:11:49.9432260Z ##[error]Notepad\CrystalReport1.cs(33,30): Error CS0115: ‘CrystalReport1.NewGenerator’: no suitable method found to override
2019-01-10T10:11:49.9433304Z ##[error]Notepad\CrystalReport1.cs(42,32): Error CS0115: ‘CrystalReport1.FullResourceName’: no suitable method found to override
I found a solution for this issue adding a pre-build event:
First I needed to add the CRRuntime msi and a pre-build.bat file to my solution:
The content for the pre-build file is an administrator installation of the CRRuntime msi. The command is: msiexec /a “%1CRRuntime_64bit_13_0_23.msi” /quiet /norestart /log “%1CRRuntime_64bit_13_0_23_install.log”. I only want this to be installed when building a release (in Azure). For this I added the condition to only install for release builds.