R# keeps breaking our release-mode build Follow
We have a file with the following code in:
#if DEBUG
string libraryDirectory = @"..\..\Methods";
#else
string libraryDirectory = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "MethodFiles");
#endif
In release build, this requires:
using System.IO;
using System.Reflection;
But in debug build, neither of these 'usings' is necessary.
The problem is that various refactoring activities (which are inevitably done with 'debug' configuration active) cause R# to remove the 'using' lines. This remains undiscovered until we commit the code, at which point the build fails.
Obviously there are several work-arounds for this, but I would really like R# not to keep deleting code which our build needs. It feels that life around the DEBUG define has gotten much harder in the more recent versions of R# - was it always this bad?
I don't actually know what the solution is, other than to analyse everything twice, once with DEBUG defined and once with out, and clearly that's expensive and doesn't scale to any other #defines anyway. But I want to complain, regardless. :-)
Please sign in to leave a comment.
Hello Will,
This is a known problem, but we won't be able to address it in the nearest
future. Could you please let me know which refactoring activities (except
Code Cleanup and Optimize Usings) can remove those using directives? Thank
you!
Andrey Serebryansky
Senior Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
Andrey,
I don't really know when it happens (that's partly what's annoying - it hides for ages and then bites us at the build server).
We have been doing a lot of moving files between folders/namespacesa, and I think the quick-fix to change a namespace to be the same as a folder name does an optimise-using type operation, so that might be it. But If I worked for JB and wanted to answer this question, I'd go to the 'Optimise Usings' method and click shift-alt-F12... ;)
Thanks!