Reputation: 825
I have code that tests which folder a project is running from to determine if it is the testing version or production version. I know there is a way to do this with the difference between debug version and released (which I want to do in the future but I don't know how yet). So for now, this is a workaround to get me what I need. This code works correctly when I run from Visual Studio but not when my scheduled task runs the compiled version.
string projectPath = System.IO.Directory.GetCurrentDirectory();
var TestVersion = true;
if (projectPath == @"H:\Automation\RefreshData\RefreshData\bin\Debug" || projectPath == @"\\atlelz1fs03.atalanta.local\USERS\Automation\RefreshData\RefreshData\bin\Debug" || projectPath == @"H:\Automation\RefreshData" || projectPath == @"\\atlelz1fs03.atalanta.local\USERS\Automation\RefreshData")
{
TestVersion = false;
}
Which folder should I be looking at for the compiled version? or is there a better way for me to determine this?
Upvotes: 0
Views: 50
Reputation: 29752
#if DEBUG
var TestVersion = true;
#endif
#if !DEBUG
var TestVersion = false;
#endif
then when in debug mode run with debug selected in visual studio (as normal) when you release this change it to Release
:
this will set TestVersion
to false
in your released code only. (BTW I have lots of configuration options, just ignore these, you will likely have Debug
and Release
only)
This works even better if you use continuous integration to compile your code for you, you can then configure this to do this, so you don't forget.
Upvotes: 3