Powershell Pro Tools - Visual Studio Community 2022

Tool: Visual Studio, Powershell Pro Tools
Version: 2022, 2021.11.0

Good Afternoon,

I am not sure if this is something I need to do but when I create a new PowerShell Windows Form Project I get the error:

Severity Code Description Project File Line Suppression State
Error The reference assemblies for .NETFramework,Version=v4.0 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at Install the .NET Framework developer pack or redistributable - .NET Framework | Microsoft Docs PowerShellFormProject1 C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets 1217

I have tried installing various SDKs/Targeting Packs but no luck - I still get the issue.

Please can someone help me.

Thanks very much

Hey, not a user of pro tools, but it says here:

That you’ll need:
Visual Studio Community, Pro or Enterprise 2017 or 2019
PowerShell v5+
.NET 4.7.2
.NET 4.6.2 (or later) Developer Pack (only required for packaging)
.NET Core 1.0 or later (only required for packaging)

I’d make sure you have these installed and reboot if you havent already.

1 Like

I’m going to run through a clean install of VS Community 2022 to see if I can reproduce this as well.

1 Like

I see the same error but it does not see to affect the function of PoshTools.

I was about to add controls to a form and run it without issue. Are you have a different experience?

I’ll open an issue to make sure we have this taken care of.

1 Like

Hi Adam,

You are right it does not seem to affect the function of PoshTools - I notice too that when you open the WYSIWYG designer the actual error disappears completely.

1 Like

Hi Adam,

Using it a little more it does appear to affect functionality - I design my form but when I go to code-behind, write some code and switch back to designer I get ‘Could not find type System.Drawing.Point’ - if I choose to ignore this error then it resets the layout of my form completely.

Ahhh yep. I can reproduce this.

I fixed it like this:

Open Solution Explorer
Expand your PowerShell Form Project
Right click on References and Click Add Reference
Navigate to the .NET Tab
Select System.Drawing from the list and click Add.
Close the form designer and reopen the form designer.

1 Like

Only problem is you have to keep doing that each time you load the project.

Also seems to affect WPF too.

On a side note, I’m trying to use PSScriptPad with VSCode and WPF but I can’t seem to move any controls I place on the form, they stay in the Center - shall I raise a new topic for this?

Cheers

We’ll get a patch out next week to resolve the issue with VS.

As for PSScriptPad, as long as you have a Grid defined within your Window, you’ll be able to drag components around.

<Window x:Name="wpfWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        Background="White"
        Title="WPF Window">
  <Grid>
    <CheckBox Width="154"
              Height="45"
              Margin="83.6666666666667,51.6666666666667,0,0"
              HorizontalAlignment="Left"
              VerticalAlignment="Top"
              Grid.Column="0"
              Grid.Row="0" />
  </Grid>
</Window>
1 Like

Good Afternoon,

Thanks for fixing WinForms (with regards to the references issue) but I see it is present on WPF too, can you reproduce this behaviour Adam?

Cheers

Hi Adam,

I am also seeing this issue. I am trying to update my packages to 5.0 and I have the patch installed (2021.11.1). I try to add references for 5 but it tries to revert to 4.8 and adds those references back in to the solution. Tried with a brand new project, just added the 5.0 references, save and close, reopen and the other 4.8 references appear. Will projects only go to 4.8?

Thanks

Currently projects will only got to .NET 4.8. I’ll have to investigate 5.0. I have opened an issue for the WPF designer.

Thanks Adam,

In the executable properties it tells me net 5.0 is available (see picture), but that obviously doesn’t work.

Would it go to 6.0 and not 5.0 as its out now???

I’m getting many reports of the .NET 5.0 packaging not working so I think there is a bug with that. It doesn’t actually use the assembly references when packaging. I hope to have a fix for the .NET 5.0 packaging this week sometime.