Readonly

Using nuget.exe in Visual Studio 2017

In earlier versions of Visual Studio before 2017 I used to create nuget packages by adding a new post-build event that deleted the old nupkg file and created a new package by invoking nuget.exe:

nuget pack "$(ProjectPath)"

This suddenly stopped working in Visual Studio 2017 – I got an error 9009 on this line, meaning that nuget.exe was not found by Visual Studio 2017. So I obtained the latest copy of nuget.exe and put it in C:\Windows\System32, executing it on the Windows console to make sure it was in the Path. It worked. But guess what? The error was still there in Visual Studio and the Visual Studio nuget console.

To make a long story short: As Visual Studio 2017 is still 32-bit, you need to place nuget.exe in C:\Windows\System32\SysWOW64 to make it work…

Readonly

Notes about System.Threading.Timer

You can fail to pass a state object to a System.Threading.Timer – you won’t see any values if you pass the instance to the timer’s constructor before initializing the values, as obviously a copy of the object is created.

The following does not work:

The timer will use 0 for object.Number.

The following, however, works as expected:

Readonly

Same column widths in WPF ListBox

You can use ItemTemplate to style the appearance of entries of a ListBox for example. Sometimes you want to use a Grid, and you want the column widths to be the same for all items of the ListBox. You can simply use the SharedSizeGroup attribute:

Don’t forget to set the Grid.IsSharedSizeGroup attribute to true for the ListBox.