The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,873 other followers

Archive for the ‘.NET’ Category

How can you export the Visual Studio Code extension list? (via: Stack Overflow)

Posted by jpluimers on 2022/06/16

Adapted from [] How can you export the Visual Studio Code extension list? – Stack Overflow, presuming that code is on the PATH:

  1. From the command-line interface on MacOS, Linux, BSD or on Windows with git installed:
    code --list-extensions | xargs -L 1 echo code --install-extension
  2. From the command-line interface on MacOS, Linux, BSD or on Windows without git installed:
    code --list-extensions | % { "code --install-extension $_" }

    or, as I think, more clearly (see also [WayBack] syntax – What does “%” (percent) do in PowerShell? – Stack Overflow):

    code --list-extensions | foreach { "code --install-extension $_" }

    or even more explanatory:

    code --list-extensions | ForEach-Object { "code --install-extension $_" }
  3. From the command-line interface on Windows as a plain cmd.exe command:
    @for /f %l in ('code --list-extensions') do @echo code --install-extension %l
  4. On Windows as a plain cmd.exe batch file (in a .bat/.cmd script):
    @for /f %%l in ('code --list-extensions') do @echo code --install-extension %%l
  5. The above two on Windows can also be done using PowerShell:
    PowerShell -Command "code --list-extensions | % { """""code --install-extension $_""""" }"

    Note that here too, the % can be expanded into foreach or ForEach-Object for clarity.

All of the above prepend “code --install-extension ” (note the trailing space) before each installed Visual Studio Code extension.

They all give you a list like this which you can execute on any machine having Visual Studio Code installed and its code on the PATH, and a working internet connection:

code --install-extension DavidAnson.vscode-markdownlint
code --install-extension ms-vscode.powershell
code --install-extension yzhang.markdown-all-in-onex

(This is about the minimum install for me to edit markdown documents and do useful things with PowerShell).

Of course you can pipe these to a text-file script to execute them later on.

The double-quote escaping is based on [Wayback/] How to escape PowerShell double quotes from a .bat file – Stack Overflow:

you need to escape the " on the command line, inside a double quoted string. From my testing, the only thing that seems to work is quadruple double quotes """" inside the quoted parameter:

powershell.exe -command "echo '""""X""""'"

Via: [] how to save your visual studio code extension list – Google Search


Posted in *nix, *nix-tools, .NET, bash, Batch-Files, CommandLine, Console (command prompt window), Development, Mac OS X / OS X / MacOS, Power User, PowerShell, PowerShell, Software Development, Visual Studio and tools, vscode Visual Studio Code, Windows, Windows 10, Windows 7, Windows 8, Windows 8.1, Windows Development, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2, Windows Server 2016, WSL Windows Subsystem for Linux, xargs | Leave a Comment »

Chocolatey 1.0.0 got released last week (chocolatey/choco · GitHub)

Posted by jpluimers on 2022/03/24

Last week finally there was the stable [Wayback/Archive] Release version 1.0.0 · chocolatey/choco · GitHub.

So I fixed the Wikipedia page

It was a few days after the 11th birthday “Celebration”: [Wayback/Archive] Chocolatey Software Blog | This One Goes To 11! Celebrating 11 Years Of Chocolatey. Not a really festive post, though it does have a really nice overview of 11 years of Chocolatey history and clearly showing the momentum of it has been a few years behind us.

The thing is: hardly anybody noticed the celebration nor the 1.0.0 release. Being at various 0.* versions for like a decade makes people not follow sudden version bumps closely. I only noticed when updating a bunch of testing VMs of which one had a problem, so I inspected the logs and saw the 1.0.0 version.

So these recent tweets did not gain much attention:

Anyway: the release notes indicate a few things scheduled for 2.0.0. Given the sudden 0.12.0 -> 1.0.0 bump, I have no clue far (or near!) in the future that will be.

It is kind of both a saddening and relieved feeling: like for instance Stack Overflow/Stack Exchange (both in the same age cohort as Chocolatey), Chocolatey is just there and mostly works.


Posted in .NET, Batch-Files, C#, Chocolatey, CommandLine, Development, Power User, PowerShell, PowerShell, Scripting, Software Development, Windows | Leave a Comment »

PowerShell debugging in Visual Studio Code: “PowerShell: Launch Current File w/Args” configuration template is missing

Posted by jpluimers on 2022/03/09

Not sure why, but most of my Visual Studio configurations have the “PowerShell: Launch Current File w/Args” debug configuration template. So here is the JSON you need to add in your launch.json configuration file.

            "type": "PowerShell",
            "request": "launch",
            "name": "PowerShell Launch Current File w/Args Prompt",
            "script": "${file}",
            "args": [
            "cwd": "${file}"

The trick is the bold part that prompts Visual Studio for the arguments.

Note: in order to have such a file, you need to have opened a folder in Visual Studio Code first, then open a PowerShell script file from that directory second.



Posted in .NET, CommandLine, Development, PowerShell, PowerShell, Scripting, Software Development | Leave a Comment »

Windows applications: storing your data in the correct place (Roaming, Local, LocalLow, not Documents)

Posted by jpluimers on 2022/03/02

This is a follow on the below TomTom HOME complaint: Know where your application should store its data.

I know this can be tough, especially for applications that were developed before Windows Vista came around: that’s when CSIDL were introduced. But still: Windows XP already had %APPDATA% (the environment variable equivalent to CSIDL_APPDATA, it pointed to %USERPROFILE%\\Application Data)

Applications should store data under either of below locations. Values are KNOWNFOLDERID constants with CSIDL constants in parenthesis where available. Some have .NET equivalents in the System.Environment.SpecialFolder enumeration:


    The file system directory that serves as a data repository for local (nonroaming) applications.

  • FOLDERID_LocalAppDataLow (n/a)

    The file system directory that serves as a data repository for local (nonroaming) applications that run under “low integrity” (like in a web browser).


     The file system directory that serves as a common repository for application-specific data.

Do not use FOLDERID_Documents (CSIDL_MYDOCUMENTS) as this is specific to user documents, not application data.

The virtual folder that represents the My Documents desktop item. This value is equivalent to CSIDL_PERSONAL.

Basically use FOLDERID_LocalAppData for data that is machine specific and FOLDERID_RoamingAppData for data that should travel to other machines when the user logs on to them.

Be very careful how much you store as potentially roamed data as these can go over slow networks (both low bandwidth and low latency).


Read the rest of this entry »

Posted in .NET, Development, Software Development, Windows Development | Leave a Comment »

.NET: XML escaping a string

Posted by jpluimers on 2022/02/15

[Wayback] WILT: XML encode a string in .net « Benoit MARTIN’s Weblog:

Always wondered why I couldn’t find a method that would XML encode a string, effectively escaping the 5 illegal characters for XML. There is such a method but its location in the API is not intuitive at all. It’s in the System.Security namespace: [Wayback] SecurityElement.Escape(String) Method (System.Security) | Microsoft Docs

public static string? Escape (string? str);

Its usage is:

   tagText = System.Security.SecurityElement.Escape(tagText);

This will escape the 5 characters <, >, &, " and '


Posted in .NET, Development, Encoding, Software Development, XML, XML escapes, XML/XSD | Leave a Comment »

%d bloggers like this: