Yesterday I wanted to build a NuGet package with a dll that references a project in the same solution. The referenced project however was not added to the installation package when I packed a new Nuget package.
I searched the internet and found some remarks about adding a parameter includereferencedprojects.
Then I came to my pack command in Azure and saw that the parameter was not in the Nuget pack task.
The YAML i had:
At first I didn’t know how to add the includereferencedprojects parameter. I then changed the “automatic package versioning” in “pack options”. I set it to “Off” and an extra checkbox was presented:
I checked the box:
And set the versioning back to the previous value.
Now my YAML included the includereferencedprojects parameter.
After I started a new build with this pipeline, the referenced project dll’s were added to my package.
I was developing a Windows service. Everything went smooth until I was asked to add logging for the service into a separate log file in the event viewer. I want to share my journey with you so it may help finding a solution for similar or the same issue.
After I had learned to install a service using a service installer, I ran into some troubles configuring the event viewer. My service had three logging options. First is to a text file on disk, second is to the Windows Event Viewer and I added an extra option to send a message to a messaging app. All service issues where logging fine. As a last option I was asked to log to a separate log in the event viewer like this:
First I tried adding all kind of options to my logging library to check, add and change the logging destination. That didn’t work and I found that the log needed to be set during initial installation of the service. Reason that previous attempts failed was that when changing these settings, the application needs admin privileges and changing logging options afterwards needed the machine to be rebooted etc.
The post of Simon Mattes in this article helped me out. I altered the code a bit for my own use:
public ProjectInstaller() { InitializeComponent(); //Skip through all ServiceInstallers. foreach (ServiceInstaller ThisInstaller in Installers.OfType()) { //Find the first default EventLogInstaller. EventLogInstaller ThisLogInstaller = ThisInstaller.Installers.OfType().FirstOrDefault(); if (ThisLogInstaller != null) { //Modify the used log from "Application" to the same name as the source name. //This creates a source in the "Applications and Services log" which separates your service logs from the default application log. ThisLogInstaller.Log = "TestApplication"; //ThisLogInstaller.Log = ThisLogInstaller.Source; ThisLogInstaller.Source = "TestSource"; } } }
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.
Last I have added a pre-build event command line for the solution: “$(ProjectDir)pre-build.bat” “$(ProjectDir)” “$(ConfigurationName)”
That’s that. Now the host will install the Crystal reports run time before building the solution.
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
Cookie
Duration
Description
cookielawinfo-checkbox-analytics
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional
11 months
The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy
11 months
The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.