Executable build error in VS 2019 (CSC : error CS8103)

Has anyone seen this error before when builing a PowerShell executable in VS 2019? I’m not seeing it in VS 2017 which builds the executable fine. The error message in the PowerShell project is fairly generic:

PowerShellProTools.targets(5,5): error : Failed to build

The build output references a temporary C# project generated to build the executable, so opening that up and building it from there provides a much better error message:

ConsolePowerShellHost.cs(54,17): warning CS0162: Unreachable code detected [C:\Users\adam\AppData\Local\Temp\f584f316a97541eaa87524930b30eeb4\EMDBT.csproj]
CSC : error CS8103: Combined length of user strings used by the program exceeds allowed limit. Try to decrease use of string literals. [C:\Users\adam\AppData\Local\Temp\f584f316a97541eaa87524930b30eeb4\EMDBT.csproj]
    1 Warning(s)
    1 Error(s)

Inside the C# project it looks like all the PowerShell code is appended to the stringBuilder. My project is generating 3406 lines here as I’m dot sourcing various scripts into the project - if I remove the dot sourced files I can complie so it does look like a limitation on the amount of PowerShell code you can add (which correlates with the error message I’m getting).

As I’m not seeing this behaviour in VS 2017 I presume it’s specific to VS 2019 - has anyone else seen this problem before and know how to resolve or know what the allowed limit is that the error refers to?

Many thanks!

Interesting. I’m surprised that there is a difference between the two versions but the error seems pretty clear.

I’ve opened an issue here and I’ll see what we can do about this in the next version: https://github.com/ironmansoftware/poshtools-issues/issues/19