NatLabRockies / NatLabRockies/OpenStudio
"OpenStudio does not work correctly on 'AnyCPU' platform. You need to specify platform (x86 or x64)"
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 646
- Forks
- 237
- Avg merge
- 3d 11h
- Merged PRs (30d)
- 10
Description
Issue overview
OpenStudio 3.7 prohibits building a C# project which is set to 'AnyCPU' as its target (which is the default). But this was not the case previously (at least not in version 3.2.1).
I haven't come across any other Nuget packages (including some with platform dependencies) that prevent building as AnyCPU. Even when they have platform dependencies; for example, https://github.com/mathnet/mathnet-numerics.
Previously our builds were all set to AnyCPU, the .NET / C# default. Using that setting most Visual Studio / MSBUILD settings and configuration could just be left in their simplest, default state. Because of this restriction against AnyCPU we've had to modify this which makes our builds more complex to maintain.
Current Behavior / Reproduction
To reproduce this, create a new .NET 8 project in Visual Studio 2022 using the "class library" project template. Then go to Nuget in VS and add OpenStudio 3.7. Compile. No code changes needed. The entire project file is listed below:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="OpenStudio" Version="3.7.0" />
</ItemGroup>
</Project>
This results in the following compilation error:
Severity Code Description Project File Line Suppression State
Error OpenStudio does not work correctly on 'AnyCPU' platform. You need to specify platform (x86 or x64). os37test <edit>\.nuget\packages\openstudio\3.7.0\build\netstandard2.0\OpenStudio.targets 5
Following the path in the error you can see where this originates, in the OpenStudio.targets file:
<Target Name="PlatformCheck" BeforeTargets="InjectReference"
Condition="(('$(Platform)' != 'x86') AND ('$(Platform)' != 'x64'))">
<Error Text="$(MSBuildThisFileName) does not work correctly on '$(Platform)' platform. You need to specify platform (x86 or x64)." />
</Target>
I attached this example: os37test.zip
This is not dependent on the .NET version, for instance it does it in .NET Framework 4.8 also.
Thanks!
Details
Environment
- Platform (Operating system, version): Windows 10, Visual Studio 2022 17.8.7
- Version of OpenStudio: 3.7.0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with the shown .NET 8 class-library project, then start with build/netstandard2.0/OpenStudio.targets and its PlatformCheck target. Done means the sample project can build with the default AnyCPU setting without emitting the reported error, with the behavior checked against the included project configuration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100