Click here to Skip to main content
15,881,516 members
Articles / Programming Languages / C#

How to Upload NLog Configuration into Version Control System?

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
9 Apr 2016CPOL3 min read 8.9K   58   1  
A discussion on how to upload NLog configuration into version control system for beginners. Two configurations are given here.

Introduction

Nlog is a very powerful logging system. We have a very good introduction from[1]. Using NuGet, we can easily integrate NLog into our .NET project. In real world software development, we need to store our project into version control system. Naturally, we will face an issue on how to manage these NLog DLLs in version control system. Here, I have shared one way to manage these NLog DLLs.

Background

I created a demo Windows Console application by the following reference [1]. Then I used Nuget to integrate NLog into this demo console application.

My project file structure looks like below:

Image 1

I set up trunk, branches and tags folder and upload this project into my version control system. Currently, I use SVN server and TortoiseSVN client to manage my project. If you browse all project folders, you will see NLog DLLs are saved under this folder NLog.4.2.3:

Image 2

Under this directory NLog4.2.3, we see the DLL:

Image 3

A Brutal Configuration

Under my current version policy, it is not allowed to upload any DLL into code repository including NLog DLLs assembly. So I set up my TortoiseSVN client ignore list as below:

Image 4

After making code changes, I decided to submit my code to SVN server through TortoiseSVN client as the following screenshot. We can see no NLog DLLs are submitted to SVN server.

Image 5

Problem

After I submit my code changes to SVN server, I need to check out for new development. Then this project contains no NLog DLLs. If we compile it, it will fail. How do we get these NLog DLLs back into this project?

Browse project folder to packages folder and we will see a folder called NLog.4.2.3, but under this folder, all NLog DLLs are missing.

Image 6

Quick Fix

After I check out the most recent version of my project, I browse into packages folder. Now remove the folder NLog.4.2.3 completely.

Then, open Visual Studio and load this project into it. From Tool menu, start NuGet manager as below:

Image 7

From search box, type "NLog" and hit enter. We will see the following screen. On the top right corner, we will a "Restore" button coming up. Please hit this Restore button, all missing NLog DLLs will be downloaded from online and show up in this project.

Image 8

After NuGet restores all missing NLog DLLs, then rebuild this project. Everything works fine.

A Cleaner Configuration

A easier and cleaner configuration is not even to upload packages folder into version control system. Automatically all NLog related DLLs will not be uploaded to version control system. The packages folder looks like the following picture:

Image 9

Here are the steps to re-load all related NLog assemblies into this project:

  1. After you check out the most recent version of your project, then open Visual Studio (my version is Visual Studio 2015). Load this project.

  2. From tool menu, select Build=>Clean Build. You will see the build is successful. No errors.

  3. Press F5 and run your application, you will see the output window in the bottom that NuGet is automatically downloading all missing NLog assemblies. Few seconds, your application starts to run. It is even cleaner.

My Understanding

The reason behind this is that there is packages.config file under the project directory. NuGet can use this configuration file to download all missing files for Nlog package.

C#
    <!--?xml version="1.0" encoding="utf-8"?-->
<packages>
  <package id="NLog" targetframework="net452" version="4.2.3">
  <package id="NLog.Config" targetframework="net452" version="4.2.3">
  <package id="NLog.Schema" targetframework="net452" version="4.0.0">

This is my way to manage NLog DLLs.

If you have a better way, please share it with the CodeProject community.

Hope you like this article. Thank you for reading!

Reference

  1. How to NLog (4.2) with VisualStudio 2015

History

  • 04-02-2016: Initialized this article
  • 04-09-2016: Updated this article

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
United States United States
turns good thoughts into actions...


Comments and Discussions

 
-- There are no messages in this forum --