Search This Blog

Tuesday, May 16, 2017

ILMerge errors (exited with code 1, could find dll, assembly has a value for its PeKind flag that is incompatible...)

After leaving very few spots in my head unscratched (I am environment-conscious, there are those who act with a bit less self restrain and throw their computers through the office's window), I came up with the following solution to ILMerge errors of all sorts. ILRepack is being developed to replace our endeared ILMerge, and although I am sure all of you keep deep feelings (feel free to make them public) about it, my solution was to:

  1. backup C:\Program Files (x86)\Microsoft\ILMerge\ILMerge.exe renaming it to, say, _ILMerge.exe 
  2. place a copy of ILRepack.exe 
  3. rename it to ILMerge.exe  (it follows the exact same ilmerge command line parameters syntax)
 And that's it. Rebuild your solution.
Yes, you are rid of ILMerge. Unbelievable.

Monday, May 8, 2017

Can't force MSBuild to use a different SDK Tools path

My scenario is: my build server, which uses Jenkins as the CI tool, runs on Windows 2008, which does not support the newer Windows 10 SDK. So I tried playing with both SDKToolsPath and FrameworkOverride msbuild command line parameters, but without success (although not the two together). I ended up trying a hack I thought of while the question from this thread (the link points to this very solution I posted there) - overwriting the lc.exe from SDK 7 with the newer LC.EXE from SDK 10. My build finally succeeded. Did not spot any side effects so far...

Thursday, May 4, 2017

Building VS projects via command line

An important thing to keep in mind when running msbuild providing properties (in the form of /p:[Key]=[Value]) (for instance, a list of properties useful in building clickonce applications can be found here) is (taken from MSDN):
Global properties are properties that are set by using the /property switch on the command line, or properties that are set by the integrated development environment (IDE) before a project is built. These global properties are applied to all projects that are built by using this Engine.
In other words, if you build a solution with 7 projects (1 start-up plus and 6, say, class libraries), and you provide the AssemblyName parameter like /p:AssemblyName=MyAssembly, you will end up with 7 assemblies with the same name, one with an EXE extension (depending on your project template) and the others with DLL. I, for instance, wanted to rename the final EXE file. Doing this using the approach above did not work for me because of the DLL name conflicts. My scenario uses Jenkins as the CI tool, and I ended up adding a Windows Batch command at the end of the process that renames the $PROJECT_NAME exe only.

Sunday, April 30, 2017

.NET built in function to convert string to into Title Case

Although a simple task, I was exposed today (here) to a built in function in the framework that does the job.


string title = "war and peace";

TextInfo textInfo = new CultureInfo("en-US"false).TextInfo;
title = textInfo.ToTitleCase(title); //War And Peace

Wednesday, April 26, 2017

Wednesday, March 8, 2017

Adding a property to a json object (either at the beginning or at the end) using Newtonsoft

Somewhere in my app I receive a JSON object, and I needed to add to it a couple of additional properties. Appending them turned out to be pretty straightforward. To add them to the beginning was not that quick.

Here's the code that does both:

string json = @"
{
    a: '123',
    b: 'avraham',
    c: { c1: 1111, c2: 'dada' }
}
"
;


var jsObject = JObject.Parse(json);
jsObject.Add("newProp", JToken.FromObject("I am a form title"));

Console.WriteLine(jsObject.ToString(Newtonsoft.Json.Formatting.Indented));
Console.WriteLine("------------- Adding property to the beginning of JSON  -----------------");

/* ------ does not work ------*/
//jsObject.AddFirst(JToken.FromObject("{formTitle: 'aaaaa'}"));
//jsObject.AddFirst("d2d2d2");
//jsObject.AddAfterSelf(JToken.FromObject("{formTitle: 'aaaaa'}"));

JObject newJObject = new JObject
(
    new JProperty("formTitle""I am a form title"),
    jsObject.Properties()
);
Console.WriteLine(newJObject.ToString(Newtonsoft.Json.Formatting.Indented));
Console.WriteLine("--------- Merging two JObjects (if the properties exist, they will be replaced/overwritten, if not, added ----------");

JObject jObjII = JObject.Parse("{x: 'x Value'}");
jObjII.Merge(jsObject);

Console.WriteLine(jObjII.ToString(Newtonsoft.Json.Formatting.Indented));

Output:


Sunday, March 5, 2017

Stop Hot Keys for Input Language Automatic Changing/Resetting

Windows 10 introduced a very annoying "feature": automatically reset your hot keys for input languages.

And the solution is not at all intuitive. Here's what you need to do (solution taken from here):



  1. Region and Language Settings
  2. Additional Date, Time & Region Settings
  3. Change input methods (under Language)
  4. Advanced Settings (Left menu/options)

Then click on "Apply language settings to the welcome screen, system accounts and new user accounts", under section "Override for Windows diplay language".

Sorry providing the walkthrough in a textual way. Too much screens to screenshot this time...