Apparently MSBuild uses environment variables to fill in it's properties. Xcode extensively uses environment to store various build information. Since CMake support for C# is very limited, i call dotnet msbuild <...> through add_custom_target(). This is what happened on MacOS builds:
Urho3DNet -> /Users/runner/work/rbfx/rbfx/cmake-build/bin/Release/Urho3DNet.dll
Urho3DNet.Scripts -> /Users/runner/work/rbfx/rbfx/cmake-build/bin/Release/Urho3DNet.dll
104_CSharpPlugin -> /Users/runner/work/rbfx/rbfx/cmake-build/bin/Release/Urho3DNet.dll
This is clearly wrong as mentioned projects set AssemblyName correctly.
After some digging i found this in msbuild log (full log):
2021-02-24T08:36:21.6415680Z TARGET_BUILD_DIR = /Users/runner/work/rbfx/rbfx/cmake-build/Source/Release
2021-02-24T08:36:21.6416300Z TARGET_NAME = Urho3DNet
2021-02-24T08:36:21.6418090Z TARGET_TEMP_DIR = /Users/runner/work/rbfx/rbfx/cmake-build/Source/rbfx.build/Release/Urho3DNet.build
2021-02-24T08:36:21.6418810Z TargetCulture = *
2021-02-24T08:36:21.6419560Z TargetDeployManifestFileName = 104_CSharpPlugin.application
2021-02-24T08:36:21.6420860Z TargetDir = /Users/runner/work/rbfx/rbfx/cmake-build/bin/Release/
2021-02-24T08:36:21.6421770Z TargetedFrameworkDir = @(_TargetedFrameworkDirectoryItem)
2021-02-24T08:36:21.6422640Z TargetedSDKArchitecture = amd64
2021-02-24T08:36:21.6423300Z TargetedSDKConfiguration = Retail
2021-02-24T08:36:21.6423840Z TargetExt = .dll
2021-02-24T08:36:21.6424300Z TargetFileName = Urho3DNet.dll
2021-02-24T08:36:21.6424820Z TargetFramework = net5.0
2021-02-24T08:36:21.6425380Z TargetFrameworkDirectory =
2021-02-24T08:36:21.6426090Z TargetFrameworkIdentifier = .NETCoreApp
2021-02-24T08:36:21.6426900Z TargetFrameworkMoniker = .NETCoreApp,Version=v5.0
2021-02-24T08:36:21.6429000Z TargetFrameworkMonikerAssemblyAttributesPath = /Users/runner/work/rbfx/rbfx/cmake-build/obj/104_CSharpPlugin/x64/Release/osx-x64/.NETCoreApp,Version=v5.0.AssemblyAttributes.cs
2021-02-24T08:36:21.6430610Z TargetFrameworkSDKToolsDirectory =
2021-02-24T08:36:21.6431350Z TargetFrameworkVersion = v5.0
2021-02-24T08:36:21.6431980Z TargetLatestRuntimePatch = false
2021-02-24T08:36:21.6432550Z TARGETNAME = Urho3DNet
2021-02-24T08:36:21.6433860Z TargetPath = /Users/runner/work/rbfx/rbfx/cmake-build/bin/Release/Urho3DNet.dll
2021-02-24T08:36:21.6434690Z TargetPlatformDisplayName =
2021-02-24T08:36:21.6435340Z TargetPlatformIdentifier =
2021-02-24T08:36:21.6436130Z TargetPlatformRegistryBase = Software\Microsoft\Microsoft SDKs\
2021-02-24T08:36:21.6436900Z TargetPlatformSdkPath =
2021-02-24T08:36:21.6437480Z TargetPlatformVersion =
2021-02-24T08:36:21.6438690Z TargetRefPath = /Users/runner/work/rbfx/rbfx/cmake-build/bin/Release/ref/Urho3DNet.dll
2021-02-24T08:36:21.6439400Z TargetRuntime = Managed
2021-02-24T08:36:21.6440370Z TargetsForTfmSpecificContentInPackage = ;PackTool;_PackProjectToolValidation
2021-02-24T08:36:21.6442000Z TEMP_DIR = /Users/runner/work/rbfx/rbfx/cmake-build/Source/rbfx.build/Release/Urho3DNet.build
2021-02-24T08:36:21.6443360Z TEMP_FILE_DIR = /Users/runner/work/rbfx/rbfx/cmake-build/Source/rbfx.build/Release/Urho3DNet.build
2021-02-24T08:36:21.6444760Z TEMP_FILES_DIR = /Users/runner/work/rbfx/rbfx/cmake-build/Source/rbfx.build/Release/Urho3DNet.build
2021-02-24T08:36:21.6446430Z TEMP_ROOT = /Users/runner/work/rbfx/rbfx/cmake-build/Source
2021-02-24T08:36:21.6447540Z TEST_FRAMEWORK_SEARCH_PATHS = /Applications/Xcode_12.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks
2021-02-24T08:36:21.6448760Z TEST_LIBRARY_SEARCH_PATHS = /Applications/Xcode_12.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib
2021-02-24T08:36:21.6449670Z TMPDIR = /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/
2021-02-24T08:36:21.6450560Z TOOLCHAIN_DIR = /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain
2021-02-24T08:36:21.6451620Z TOOLCHAINS = com.apple.dt.toolchain.XcodeDefault
Looks like all-caps variables come from Xcode. Unsetting TARGETNAME TARGET_NAME makes build failures go away.
This is not the first time i am experiencing similar problem. Something in the past from Xcode also messed up environment, so until recently i did MacOS builds with env -i msbuild command prefix. Now that dotnet does need some environment variables this is no longer an option.
Proposed solution: a way to turn prevent msbuild from using environment variables for properties that are not related to setup of the environment.
This should be magically fixed along with #2713. I don't know of a timeline on that, currently.
Sounds like it. Should this issue be closed then?
Optional? That one can't be resolved without resolving this, but this one can be resolved without resolving that. I can't promise a date on 2713鈥攑artially given how old it is鈥攂ut it's at least something we'd like to do.
Most helpful comment
This should be magically fixed along with #2713. I don't know of a timeline on that, currently.