There are many other (older) MSB3270 mismatch errors questions posted on SO, but many of them are a decade old and for generations before NET 5. I have a set of NET 5 solutions that are all set to Debug AnyCPU in the Build / Configuration Manager. Yet I still get the warning message about mismatched architectures.
Here is my MSBuild command line:
%msbdir%\msbuild -nologo -m -V:q "%1" /t:Clean;Restore;Rebuild;Publish
/p:PublishProtocol=FileSystem /p:PublishDir=%coredir% /p:RuntimeIdentifier=win-x64
Here is the output:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin
Microsoft.Common.CurrentVersion.targets(2203,5): warning MSB3270: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "HsLogger", "AMD64". 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. [c:\dev\HsUtils.csproj] Publish Ok - hsutils\hsutils.sln to c:\dev\holding\core.plt
I am certain that everything is set to Debug AnyCPU, so why is MSBuild protesting? I read somewhere else that AnyCPU is pretty meaningless and that I should specify x64 or x32 (or both) in my build configurations. I have net5.0-windows7.0
for a TargetFramework in the project files, but nothing else (no RunTimeIdentifier settings).
I wonder if the msbuild parameter /p:RuntimeIdentifer=win-x64
has something to do with it, but I don't know enough for sure. Should I be explicitly adding runtime identifiers to all my project files?
Is explicitly picking x64 the way out of these warnings, or should I just suppress them in my MsBuild command-line options? (Suppression seems like a bad move because it's a pretty serious issue if there is a true mismatch.) Thank you
UPDATE
In case it helps, my project files all look like this:
<PropertyGroup>
<TargetFramework>net5.0-windows7.0</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>false</SelfContained>
<PublishReadyToRun>true</PublishReadyToRun>
</PropertyGroup>