Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It should add Prefer32Bit when it's false rather than true. #1473

Closed
CreateAndInject opened this issue Mar 31, 2019 · 5 comments

Comments

Projects
None yet
2 participants
@CreateAndInject
Copy link
Contributor

commented Mar 31, 2019

ILSpy must add Prefer32Bit node when it's false rather than true, the default Prefer32Bit value is true, that means:
If the TargetFramework is 4.5+, and Prefer32Bit is false, you must add Prefer32Bit=false in csproj.
And if the Prefer32Bit is true, there's no necessary to add Prefer32Bit node, true is the default value.
Of course, if the TargetFramework is less than 4.5, Prefer32Bit can't be true.
For example, if a program is builded as .net 4.5 without Prefer32Bit, when rebuild it using decompilation code, it will become to Prefer32Bit. If a program is builded as .net 4.5 with Prefer32Bit, when rebuild it using decompilation code, it will keep Prefer32Bit even if no Prefer32Bit node. So the rebuild program will allways be Prefer32Bit!

So, only when platform is AnyCPU, and Prefer32Bit is false and TargetFramework is 4.5+, you need to add a Prefer32Bit node.
By the way, please use 'false' instead of 'False' to keep the same as Visual Studio.

@siegfriedpammer

This comment has been minimized.

Copy link
Member

commented May 10, 2019

Do you have any documentation that states that Prefers32Bit defaults to true on framework v4.5 and later?

I just tried a simple console app with the following project file:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFrameworks>net20;net30;net40;net45;net462</TargetFrameworks>
  </PropertyGroup>

</Project>

The targets > v4.0 do not have the CorFlags.Prefers32Bit flag set in the cor header.

@CreateAndInject

This comment has been minimized.

Copy link
Contributor Author

commented May 10, 2019

The output of ILSpy is old project format, not sdk project, like this:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <ProjectGuid...

So, please test again with old project format ( such as create a WinForm project)

@siegfriedpammer

This comment has been minimized.

Copy link
Member

commented May 10, 2019

I just tested this with a Windows Forms old-style project on framework v4.5. Prefers32Bit is not set implicitly.

Can you please provide an example project including the original source, so I can check what the problem is? Thank you very much!

@CreateAndInject

This comment has been minimized.

Copy link
Contributor Author

commented May 10, 2019

@siegfriedpammer

This comment has been minimized.

Copy link
Member

commented May 10, 2019

Thank you for pointing this out. I managed to reproduce the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.