MSBuild not working with C# library project referenced from an Oxygene library project

Hi Remobjects

Having difficulty in getting our CI system (TeamCity) to build some of our solutions since updating to latest version of elements. I can also repro the problem by using msbuild as well.

MixedLibTest.zip (8.5 KB)

Attached is a small solution to demonstrate

don’t use VS to compile but use VS command prompt instead and issue following

msbuild MixedLibTest.sln /t:oxygenelib:rebuild /p:configuration=release

I get the following error

“C:\Users\afelton\Source\Repos\MixedLibTest\MixedLibTest.sln” (oxygenelib:rebuild target) (1) ->
“C:\Users\afelton\Source\Repos\MixedLibTest\OxygeneLib\OxygeneLib.elements” (Rebuild target) (2) ->
(Rebuild target) ->
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\RemObjects Software\Elements\RemObjects.Elements.targets(70,3): EBuild error : Reference ‘CS
harpLib’ could not be resolved for target ‘Echoes’ (Echoes .NET anycpu). [C:\Users\afelton\Source\Repos\MixedLibTest\OxygeneLib\OxygeneLib.elements]

Thanks
Alex

Thanks, logged as bugs://83365

FWIW, for me (on Mac, with xbuild), the .csproj doesn’t build, dozens of missing types/references)

The .csproj project only has 1 empty class and thats it, and I don’t think old school .Net framework projects would compile on a mac anyway

just reporting what I see.

xbuild CSharpLib/CSharpLib.csproj:

Properties/AssemblyInfo.cs(8,12): error CS0246: The type or namespace name 'AssemblyTitleAttribute' could not be found (are you missing a using directive or an assembly reference?)
Properties/AssemblyInfo.cs(8,12): error CS0246: The type or namespace name 'AssemblyTitle' could not be found (are you missing a using directive or an assembly reference?)
Properties/AssemblyInfo.cs(9,12): error CS0246: The type or namespace name 'AssemblyDescriptionAttribute' could not be found (are you missing a using directive or an assembly reference?)
Properties/AssemblyInfo.cs(9,12): error CS0246: The type or namespace name 'AssemblyDescription' could not be found (are you missing a using directive or an assembly reference?)
Properties/AssemblyInfo.cs(10,12): error CS0246: The type or namespace name 'AssemblyConfigurationAttribute' could not be found (are you missing a using directive or an assembly reference?)
Properties/AssemblyInfo.cs(10,12): error CS0246: The type or namespace name 'AssemblyConfiguration' could not be found (are you missing a using directive or an assembly reference?)
Properties/AssemblyInfo.cs(11,12): error CS0246: The type or namespace name 'AssemblyCompanyAttribute' could not be found (are you missing a using directive or an assembly reference?)
Properties/AssemblyInfo.cs(11,12): error CS0246: The type or namespace name 'AssemblyCompany' could not be found (are you missing a using directive or an assembly reference?)
Properties/AssemblyInfo.cs(12,12): error CS0246: The type or namespace name 'AssemblyProductAttribute' could not be found (are you missing a using directive or an assembly reference?)
Properties/AssemblyInfo.cs(12,12): error CS0246: The type or namespace name 'AssemblyProduct' could not be found (are you missing a using directive or an assembly reference?)
Properties/AssemblyInfo.cs(13,12): error CS0246: The type or namespace name 'AssemblyCopyrightAttribute' could not be found (are you missing a using directive or an assembly reference?)
Properties/AssemblyInfo.cs(13,12): error CS0246: The type or namespace name 'AssemblyCopyright' could not be found (are you missing a using directive or an assembly reference?)
Properties/AssemblyInfo.cs(14,12): error CS0246: The type or namespace name 'AssemblyTrademarkAttribute' could not be found (are you missing a using directive or an assembly reference?)
Properties/AssemblyInfo.cs(14,12): error CS0246: The type or namespace name 'AssemblyTrademark' could not be found (are you missing a using directive or an assembly reference?)
Properties/AssemblyInfo.cs(15,12): error CS0246: The type or namespace name 'AssemblyCultureAttribute' could not be found (are you missing a using directive or an assembly reference?)
Properties/AssemblyInfo.cs(15,12): error CS0246: The type or namespace name 'AssemblyCulture' could not be found (are you missing a using directive or an assembly reference?)
Properties/AssemblyInfo.cs(20,12): error CS0246: The type or namespace name 'ComVisibleAttribute' could not be found (are you missing a using directive or an assembly reference?)
Properties/AssemblyInfo.cs(20,12): error CS0246: The type or namespace name 'ComVisible' could not be found (are you missing a using directive or an assembly reference?)
Properties/AssemblyInfo.cs(23,12): error CS0246: The type or namespace name 'GuidAttribute' could not be found (are you missing a using directive or an assembly reference?)
Properties/AssemblyInfo.cs(23,12): error CS0246: The type or namespace name 'Guid' could not be found (are you missing a using directive or an assembly reference?)
Properties/AssemblyInfo.cs(35,12): error CS0246: The type or namespace name 'AssemblyVersionAttribute' could not be found (are you missing a using directive or an assembly reference?)
Properties/AssemblyInfo.cs(35,12): error CS0246: The type or namespace name 'AssemblyVersion' could not be found (are you missing a using directive or an assembly reference?)
Properties/AssemblyInfo.cs(36,12): error CS0246: The type or namespace name 'AssemblyFileVersionAttribute' could not be found (are you missing a using directive or an assembly reference?)
Properties/AssemblyInfo.cs(36,12): error CS0246: The type or namespace name 'AssemblyFileVersion' could not be found (are you missing a using directive or an assembly reference?)
obj/Debug/.NETFramework,Version=v4.8.AssemblyAttribute.cs(2,46): error CS0234: The type or namespace name 'TargetFrameworkAttributeAttribute' does not exist in the namespace 'System.Runtime.Versioning' (are you missing an assembly reference?)
obj/Debug/.NETFramework,Version=v4.8.AssemblyAttribute.cs(2,46): error CS0234: The type or namespace name 'TargetFrameworkAttribute' does not exist in the namespace 'System.Runtime.Versioning' (are you missing an assembly reference?)
Properties/AssemblyInfo.cs(8,26): error CS0518: Predefined type 'System.String' is not defined or imported
Properties/AssemblyInfo.cs(9,32): error CS0518: Predefined type 'System.String' is not defined or imported
Properties/AssemblyInfo.cs(10,34): error CS0518: Predefined type 'System.String' is not defined or imported
Properties/AssemblyInfo.cs(11,28): error CS0518: Predefined type 'System.String' is not defined or imported
Properties/AssemblyInfo.cs(12,28): error CS0518: Predefined type 'System.String' is not defined or imported
Properties/AssemblyInfo.cs(13,30): error CS0518: Predefined type 'System.String' is not defined or imported
Properties/AssemblyInfo.cs(14,30): error CS0518: Predefined type 'System.String' is not defined or imported
Properties/AssemblyInfo.cs(15,28): error CS0518: Predefined type 'System.String' is not defined or imported
Properties/AssemblyInfo.cs(20,23): error CS0518: Predefined type 'System.Boolean' is not defined or imported
Properties/AssemblyInfo.cs(23,17): error CS0518: Predefined type 'System.String' is not defined or imported
Properties/AssemblyInfo.cs(35,28): error CS0518: Predefined type 'System.String' is not defined or imported
Properties/AssemblyInfo.cs(36,32): error CS0518: Predefined type 'System.String' is not defined or imported
obj/Debug/.NETFramework,Version=v4.8.AssemblyAttribute.cs(2,71): error CS0518: Predefined type 'System.String' is not defined or imported
obj/Debug/.NETFramework,Version=v4.8.AssemblyAttribute.cs(2,101): error CS0246: The type or namespace name 'FrameworkDisplayName' could not be found (are you missing a using directive or an assembly reference?)
obj/Debug/.NETFramework,Version=v4.8.AssemblyAttribute.cs(2,124): error CS0518: Predefined type 'System.String' is not defined or imported
Properties/AssemblyInfo.cs(1,14): error CS0234: The type or namespace name 'Reflection' does not exist in the namespace 'System' (are you missing an assembly reference?)
CSharpClass.cs(9,18): error CS0518: Predefined type 'System.Object' is not defined or imported

Mono should compile any standard .csproj fine, normally.

Have no Idea why it’s got all those errors, the project was created using C# .Net Framework Class Library with no additions, all compiles fine in VS, just a problem when I use msbuild CLI, all on windows

Yeah, doesn’t really matter, as someone form the VS team needs to have a look, anyways. Just found it odd that it didn’t compile on Mono…

I”m really finding this very hard to understand what is really going on and who’s supposed to do what. Is the problem that when the oxygene compiler is being called, it’s not detecting that the referenced .csproj project needs compiling before using the referenced dll, or is msbuild supposed to do that. All this used to work fine before your new and improved ebuild thing. Up to now since the new ebuild thing lots of my projects that had been fine for years are running into issues, some of which I’ve managed to muddle my way through to get working again.
Is this a remobjects or ms issue, if ms? Why? As all this used to work fine in the past

Alex

It’s hard to say until someone had a chance to look a the project.

Just so you know, to get around the problem I have to pre-build the C# projects, then the Oxygene projects build ok. ie multiple calls to msbuild. Not satisfactory but it works at least.

1 Like

My apologies this wasn’t looked at yet even though I had asked someone too. I’ll go yell a bit…

Thanks, logged as bugs://83394

Hello Alex,
I checked the projects you sent, and found that VS C# is not referenced as a project. It is referenced as a simple reference, like:

>  <HintPath>C:\Users\afelton\Source\Repos\MixedLibTest\CSharpLib\bin\Release\CSharpLib.dll</HintPath>
>     <Private>True</Private>
>  </Reference>

So obviously msbuild doesn’t know that it must build VS C# project first and can’t resolve the reference until the dll is not in the HintPath.
I also checked VS2017 on how it adds project references. It creates something like:

  <ItemGroup>
    <ProjectReference Include="..\ClassLibrary1\ClassLibrary1.csproj">
      <Name>ClassLibrary1</Name>
      <Project>{a45caa8f-d83f-45ae-b202-dd058a484e5c}</Project>
      <Private>True</Private>
      <HintPath>..\ClassLibrary1\bin\Debug\ClassLibrary1.dll</HintPath>
    </ProjectReference>
  </ItemGroup>

Please, check that all your projects have proper ProjectReferences. It must solve the problem.
Hope that helps.

Hi Viktor
If the project wasn’t using a ProjectReference, that was a mistake, as I do actually use them, but the problem is actually visible in your example. Notice the path in the hint, …/bin/debug/… If you do a clean, then switch from debug to release config, it should fail moaning it can’t find the dll when you do a compile

Alex

Something I completely forgot about was the legacy target, if I use it things start to work much better, though Marc did say something about it being deprecated. Currently the regular target breaks most, if not all of my builds, a lot of which have been fine for many years. From what I gather Remobjects seems to have changed it’s priorities and is more focused with all the IOS/Android/native compiling using Water and have left people like me, who have lots of .net solutions in VS, in an awkward position. To be honest if there was a button I could push that would translate all the pascal to C# I would regretfully use it and drop oxygene entirely. At the moment it’s causing me lots of waisted time trying to get things to work properly and keep finding myself in a loosing battle
Alex

Nothing could be further from the truth.

But we need a build chain that can support all platforms, in a maintainable form — and MSBuild alone was not that.

The legacy target is there to use, for standard desktop .NET projects, while we work out remaining kinks like these. It’ll keep working for the foreseeable future, unless you target other platforms or . NET Core that require the new targets file and build chain.

Alex I hope we didn’t give you that impression. While have done a lot of changes for native code, it’s pretty much to bring them up to par with how the .NET backend is now. We introduced EBuild because we were hitting the limits of what is possible with MSBuild.

OK, well that’s good to know. It might of been more user friendly if a new target, say RemObjects.Elements.Echoes.EBuild.targets, was created instead of renaming the existing one to Legacy, then at least projects like mine would of just carried on working, and use the new target for new projects or even have the option to choose. At the least, it would of been nice to have been warned about the breaking change at the time of the release.

Is it the goal for EBuild to be fully compatible with older MSBuild projects or should I just change all the targets of my existing projects to Legacy now?

bugs://83394 got closed with status fixed.

bugs://83365 got closed with status fixed.