DEV Community


Posted on

Azure Pipelines w/ .NET 4.7.2

Today, I built my first basic CI process in Azure Pipelines and ran into a few issues along the way. I might come back to add the actual error messages for better context but anyway, here's what I can remember. Next time I'll take better notes.

The project is a .NET Framework console application I wrote a few years ago to solve a small problem at work. I recently overhauled the project to work with updates to an external system and decided it was a good time to build a pipeline to simplify/codify my deployment and pass that knowledge onto my team members.

Pretty much every example these days is for ASP.NET Core or another modern relative of .NET, so it took some time to figure out that I needed to use the VSBuild action in the pipeline and not DotNetCoreCLI. I thought maybe you could point the dotnet task at an older framework and it would understand, but it only works with dotnet core. Silly me.

My first issue was that I did not have my Settings.Designer.cs file under version control. Apparently, this file is generated by Visual Studio and lives under the Settings.settings file in your source tree.

Initially, I had the settings files ignored because I had a few credentials saved there during mock up and testing and didn't want them in my commits. Don't be like me, there are better ways, even when testing. I had long since removed the credentials from testing and added the Settings.settings file to my repo.

It turns out when I un-ignored Settings.settings, I did not un-ignore Settings.Designer.cs and that caused the build to fail because it couldn't find the file for a copy action in the build process. Removing that line from my .gitignore and committing the change fixed that problem.

Next, I had a reference in the .csproj file to credentials.json with a Copy to Output Directory setting of Copy always. Find these settings in the Properties window under the Solution Explorer. Again, this file was not in version control for obvious reasons, but the copy action was leftover from local testing. I changed the setting, rebuilt the project locally so the .csproj would be updated and committed the changes.

This fix likely would have worked for the Settings.Designer.cs file as well, but internet wisdom seemed to indicate it was better to keep it in the project files even though it will be regenerated by Visual Studio.

Note that the build tools will not regenerate this file for you in the pipeline.

After that, my project built successfully for the first time in Azure Pipelines!

I spent the rest of the time working on getting the pipeline to produce the build artifact as a .zip containing the .exe and associated project files.

A few notes from working with the azure-pipelines.yml file:

Discussion (0)