Monday, November 26, 2001 ..:: Home ::.. Register  Login
   TechTidBits (Blog)  

Attaching non-code files to your project, how hard can it be?

Oct 13

Written by:
Saturday, October 13, 2018 3:10 PM  RssIcon

This week at work, I was looking at our automation solution and wondering about adding a non-code file for future coworkers to use as reference. Easy enough, add the file…but then is the tough question, do you want it to be included in the compiled output? What I mean is, do you or your intended audience (including your code) need access to this file or these files at runtime?

What’s the difference? Well, if you’re including a ReadMe.txt file, you likely won’t want that in the compiled code (in \bin\Debug or \bin\Release). However, if you want a JSON file or an XML file or even XLS or PDF files for comparison sake, then for sure you want those included. But how do you do it?

First off, I would suggest making a folder\directory for those files so they are not confused with other code files. Next place your file in there, then hit F4 or goto the file’s Properties.

If you’re looking at a ReadMe.txt file, make sure None is selected. If you WANT it included, then you should select Content. This way, you’ll be able to use .NET APIs (that’s for another blog) and gain access to your files. If you want to test this out, after adding your file, do an F6 or compile, then look at the \bin\Debug directory.

Another suggestion would be to change the Copy to Output option to Only if Newer. That way you’re not constantly copying the same file over and over again unnecessarily…especially if your files are large, huge, GINORMOUS!

Now that you know how to include supplemental\extra non-code files into your output, it’s not that hard at all.


stackoverflow = What are the various “Build action” settings in Visual Studio project properties and what do they do?

stackoverflow = What do the different build actions do in a csproj. I.e. AdditionalFiles or Fakes

Location: Blogs Parent Separator TechTidBits

Your name:
Gravatar Preview
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Add Comment   Cancel 
Copyright 1999-2012 by   Terms Of Use  Privacy Statement