ironmansoftware / powershell-pro-tools

Scripting, automation, and development tools for professionals working with PowerShell.
MIT License
44 stars 1 forks source link

Bug: All projects and solutions created with Powershell Pro Tools (Winforms Template) are throwing an error. "There was a mismatch between the processor architecture of the project being built 'MSIL' and the processor architecture of the reference" #25

Open futuremotiondev opened 1 year ago

futuremotiondev commented 1 year ago

Describe the bug

When I create a new PowerShell Windows Forms project (Using the Powershell Pro Tools Template) and then load it later, I am getting the following error message:

There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "C:\Windows\Microsoft.NET\Framework\v4.0.30319\\mscorlib.dll", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project. 

The additional columns in the error:

Project: DemucsForm    
Path:    C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64
File:    Microsoft.Common.CurrentVersion.targets
Line:    2352
Col:     6
Source:  Build

devenv_HPQx2i2cly

After reading a bunch of other posts on StackOverflow about this error (although none I've seen have a reference to the x86 version of mscorlib.dll) it seems that my project isn't technically "AnyCPU" because there is an x86 dependency, which again happens to be mscorlib.dll.

But this doesn't make sense to me - why does this even matter since I'm not actually "compiling" or "building" a project (since it's PowerShell)?

  1. Why are all my new PowerShell projects via Powershell Pro Tools adding a dependency to the x86 version of mscorlib.dll from .NET Framework v4.0.30319? I didn't manually add any assemblies.
  2. Why isn't a newer version of the mscorlib.dll assembly being referenced? Isn't .NET v4.0.30319 ancient?
  3. Does this message even matter? Can I safely ignore it?
  4. If it does matter, how can I resolve the problem? I can't find a way to remove this dependency.
  5. If it doesn't matter, how can I universally suppress this message for all future projects?

I really want to get to the bottom of this. I also posted a question about this exact problem on StackOverflow to get some more visibility. Here it is.

To Reproduce Steps to reproduce the behavior:

  1. Create a new Powershell Windows Forms project:

devenv_d0B7J5o7ck

  1. Create a simple test GUI with a few different components. Here's mine:

devenv_r4xwJcGF79

  1. Save the solution/project somewhere, and then close the solution and exit Visual Studio 2022.

  2. Reopen Visual Studio 2022 and then open your solution.

  3. You should now see the error I outlined in the Error List panel on the bottom of the screen:

devenv_kgtymvGGp4

Expected behavior There should be no error about mscorlib.dll.

Version

Microsoft Visual Studio Community 2022 (64-bit) Version 17.5.0 Powershell Pro Tools Extension: Version 2023.2.0 Operating System: Windows 10 Pro, Version 22H2 Build 19045.2604

Additional context Nothing to add.

Logs

Please upload a log. Logs are found in $Env:AppData\PowerShellProTools\ by default.

On my computer that directory doesn't exist. But I found a bunch of logs at C:\Users\[username]\AppData\Roaming\PowerShell Tools for Visual Studio

Here are the last five logs:

Logs.zip

Here is a zip containing the testing solution I created. If you open this in VS2022, you should see the error.

DebugTesting.zip

Any help at all would be great. I hope your team can manage to find and fix this!

Jay

DataTraveler1 commented 1 year ago

@visusys - As a workaround, you can try adding mscorlib as a reference per below. This removes the warning immediately.

image

Can you advise if this helps? There's a lot of good questions in this post which I will help to research the answers for 👍