I am seeing an issue where code retrieved from the repo and built on the CI machine fails with tons of The type of namespace name '(name)' could not be found (are you missing a using directive or an assembly reference?) errors. If I check out a fresh copy of the code and attempt a build using the exact same "nuget restore" and "MSBuild" commands from the Mac OS X Terminal window on my local machine, the build has no problems.
I noticed that the CoreCompile commands are different between the CI machine and my local machine. I've copied an example where the same source files are being compiled. In the first block, taken from the CI machine, there are no /reference: entries, only source .cs files. In the second block, the /reference: entries are specified and things work as expected.
Does anyone know why the references wouldn't be present in the CI build attempt?
Thanks!
CI machine example, no /reference: entries, compile fails due to missing assembly references
CoreCompile:
/Library/Frameworks/Mono.framework/Versions/5.2.0/lib/mono/4.5/csc.exe /noconfig /unsafe- /checked- /nowarn:1701,1702,1705 /nostdlib+ /errorreport:prompt /warn:4 /define:TRACE;RELEASE;NETSTANDARD1_0 /debug- /debug:portable /filealign:512 /nologo /optimize+ /out:obj/Release/netstandard1.0/Plugin.BluetoothLE.Abstractions.dll /target:library /warnaserror- /utf8output /deterministic+ AbstractAdapter.cs AbstractDevice.cs AbstractGattCharacteristic.cs AbstractGattDescriptor.cs AbstractGattReliableWriteTransaction.cs AbstractGattService.cs AdapterFeatures.cs AdapterStatus.cs AdvertisementRecordType.cs BleScanType.cs BleWriteSegment.cs CharacteristicEvent.cs CharacteristicProperties.cs CharacteristicResult.cs ClearableReplaySubject.cs ConnectionPriority.cs ConnectionStatus.cs DescriptorEvent.cs DescriptorResult.cs DeviceFeatures.cs Dictionaries.cs Extensions_Adapter.cs Extensions_Characteristics.cs Extensions_Device.cs Extensions_Rx.cs GattConnectionConfig.cs GattReliableWriteTransactionException.cs HeartRateExtensions.cs IAdapter.cs IAdapterScanner.cs IAdvertisementData.cs IDevice.cs IGattCharacteristic.cs IGattDescriptor.cs IGattReliableWriteTransaction.cs IGattService.cs IScanResult.cs Log.cs PairingStatus.cs Properties/AssemblyInfo.cs ScanConfig.cs ScanResult.cs Server/AbstractGattCharacteristic.cs Server/AbstractGattDescriptor.cs Server/AbstractGattServer.cs Server/AbstractGattService.cs Server/AdvertisementData.cs Server/CharacteristicBroadcast.cs Server/CharacteristicSubscription.cs Server/DeviceSubscriptionEvent.cs Server/GattPermissions.cs Server/GattStatus.cs Server/IDevice.cs Server/IGattCharacteristic.cs Server/IGattDescriptor.cs Server/IGattServer.cs Server/IGattService.cs Server/ManufacturerData.cs Server/ReadRequest.cs Server/WriteRequest.cs TransactionStatus.cs VoidGattReliableWriteTransaction.cs ../Plugin.BluetoothLE.Shared/CommonAssemblyInfo.cs "/var/folders/87/7vh704qd4ll6wky04vmnr5380000gn/T/.NETStandard,Version=v1.0.AssemblyAttributes.cs"
Local machine example, compiles successfully
CoreCompile:
/Library/Frameworks/Mono.framework/Versions/5.4.1/lib/mono/4.5/csc.exe /noconfig /unsafe- /checked- /nowarn:1701,1702,1705 /nostdlib+ /errorreport:prompt /warn:4 /define:TRACE;RELEASE;NETSTANDARD1_0 /reference:/Users/ansuriasolutions/.nuget/packages/system.collections/4.3.0/ref/netstandard1.0/System.Collections.dll /reference:/Users/ansuriasolutions/.nuget/packages/system.componentmodel/4.0.1/ref/netstandard1.0/System.ComponentModel.dll /reference:/Users/ansuriasolutions/.nuget/packages/system.diagnostics.contracts/4.0.1/ref/netstandard1.0/System.Diagnostics.Contracts.dll /reference:/Users/ansuriasolutions/.nuget/packages/system.diagnostics.debug/4.3.0/ref/netstandard1.0/System.Diagnostics.Debug.dll /reference:/Users/ansuriasolutions/.nuget/packages/system.diagnostics.tools/4.3.0/ref/netstandard1.0/System.Diagnostics.Tools.dll /reference:/Users/ansuriasolutions/.nuget/packages/system.dynamic.runtime/4.0.11/ref/netstandard1.0/System.Dynamic.Runtime.dll /reference:/Users/ansuriasolutions/.nuget/packages/system.globalization/4.3.0/ref/netstandard1.0/System.Globalization.dll /reference:/Users/ansuriasolutions/.nuget/packages/system.io/4.3.0/ref/netstandard1.0/System.IO.dll /reference:/Users/ansuriasolutions/.nuget/packages/system.linq/4.3.0/ref/netstandard1.0/System.Linq.dll /reference:/Users/ansuriasolutions/.nuget/packages/system.linq.expressions/4.3.0/ref/netstandard1.0/System.Linq.Expressions.dll /reference:/Users/ansuriasolutions/.nuget/packages/system.net.primitives/4.3.0/ref/netstandard1.0/System.Net.Primitives.dll /reference:/Users/ansuriasolutions/.nuget/packages/system.objectmodel/4.3.0/ref/netstandard1.0/System.ObjectModel.dll /reference:/Users/ansuriasolutions/.nuget/packages/system.reactive.core/3.1.1/lib/netstandard1.0/System.Reactive.Core.dll /reference:/Users/ansuriasolutions/.nuget/packages/system.reactive.interfaces/3.1.1/lib/netstandard1.0/System.Reactive.Interfaces.dll /reference:/Users/ansuriasolutions/.nuget/packages/system.reactive.linq/3.1.1/lib/netstandard1.0/System.Reactive.Linq.dll /reference:/Users/ansuriasolutions/.nuget/packages/system.reactive.platformservices/3.1.1/lib/netstandard1.0/System.Reactive.PlatformServices.dll /reference:/Users/ansuriasolutions/.nuget/packages/system.reflection/4.3.0/ref/netstandard1.0/System.Reflection.dll /reference:/Users/ansuriasolutions/.nuget/packages/system.reflection.extensions/4.3.0/ref/netstandard1.0/System.Reflection.Extensions.dll /reference:/Users/ansuriasolutions/.nuget/packages/system.reflection.primitives/4.3.0/ref/netstandard1.0/System.Reflection.Primitives.dll /reference:/Users/ansuriasolutions/.nuget/packages/system.resources.resourcemanager/4.3.0/ref/netstandard1.0/System.Resources.ResourceManager.dll /reference:/Users/ansuriasolutions/.nuget/packages/system.runtime/4.3.0/ref/netstandard1.0/System.Runtime.dll /reference:/Users/ansuriasolutions/.nuget/packages/system.runtime.extensions/4.3.0/ref/netstandard1.0/System.Runtime.Extensions.dll /reference:/Users/ansuriasolutions/.nuget/packages/system.runtime.interopservices.windowsruntime/4.0.1/ref/netstandard1.0/System.Runtime.InteropServices.WindowsRuntime.dll /reference:/Users/ansuriasolutions/.nuget/packages/system.text.encoding/4.3.0/ref/netstandard1.0/System.Text.Encoding.dll /reference:/Users/ansuriasolutions/.nuget/packages/system.text.encoding.extensions/4.3.0/ref/netstandard1.0/System.Text.Encoding.Extensions.dll /reference:/Users/ansuriasolutions/.nuget/packages/system.text.regularexpressions/4.3.0/ref/netstandard1.0/System.Text.RegularExpressions.dll /reference:/Users/ansuriasolutions/.nuget/packages/system.threading/4.3.0/ref/netstandard1.0/System.Threading.dll /reference:/Users/ansuriasolutions/.nuget/packages/system.threading.tasks/4.3.0/ref/netstandard1.0/System.Threading.Tasks.dll /reference:/Users/ansuriasolutions/.nuget/packages/system.xml.readerwriter/4.3.0/ref/netstandard1.0/System.Xml.ReaderWriter.dll /reference:/Users/ansuriasolutions/.nuget/packages/system.xml.xdocument/4.3.0/ref/netstandard1.0/System.Xml.XDocument.dll /debug- /debug:portable /filealign:512 /nologo /optimize+ /out:obj/release/netstandard1.0/Plugin.BluetoothLE.Abstractions.dll /target:library /warnaserror- /utf8output /deterministic+ AbstractAdapter.cs AbstractDevice.cs AbstractGattCharacteristic.cs AbstractGattDescriptor.cs AbstractGattReliableWriteTransaction.cs AbstractGattService.cs AdapterFeatures.cs AdapterStatus.cs AdvertisementRecordType.cs BleScanType.cs BleWriteSegment.cs CharacteristicEvent.cs CharacteristicProperties.cs CharacteristicResult.cs ClearableReplaySubject.cs ConnectionPriority.cs ConnectionStatus.cs DescriptorEvent.cs DescriptorResult.cs DeviceFeatures.cs Dictionaries.cs Extensions_Adapter.cs Extensions_Characteristics.cs Extensions_Device.cs Extensions_Rx.cs GattConnectionConfig.cs GattReliableWriteTransactionException.cs HeartRateExtensions.cs IAdapter.cs IAdapterScanner.cs IAdvertisementData.cs IDevice.cs IGattCharacteristic.cs IGattDescriptor.cs IGattReliableWriteTransaction.cs IGattService.cs IScanResult.cs Log.cs PairingStatus.cs Properties/AssemblyInfo.cs ScanConfig.cs ScanResult.cs Server/AbstractGattCharacteristic.cs Server/AbstractGattDescriptor.cs Server/AbstractGattServer.cs Server/AbstractGattService.cs Server/AdvertisementData.cs Server/CharacteristicBroadcast.cs Server/CharacteristicSubscription.cs Server/DeviceSubscriptionEvent.cs Server/GattPermissions.cs Server/GattStatus.cs Server/IDevice.cs Server/IGattCharacteristic.cs Server/IGattDescriptor.cs Server/IGattServer.cs Server/IGattService.cs Server/ManufacturerData.cs Server/ReadRequest.cs Server/WriteRequest.cs TransactionStatus.cs VoidGattReliableWriteTransaction.cs ../Plugin.BluetoothLE.Shared/CommonAssemblyInfo.cs "/var/folders/n9/k01tq4vx2b72k_v9w05jn5dc0000gn/T/.NETStandard,Version=v1.0.AssemblyAttributes.cs" /warnaserror+:NU1605
My guess is that the version of nuget on the CI server is too old and so does not support generating an obj/project.assets.json file for your .NET Standard project. This file will contain the reference information required by msbuild.
Mono 5.2 ships with nuget 2.12. Whilst Mono 5.4 ships with NuGet 4.3. NuGet v2 does not support the newer project formats when running a restore.
Another alternative, if the project is an SDK style project, or uses PackageReferences, would be to use msbuild /t:restore
to generate the project.assets.json file.
I think the simplest solution here would be to update Mono on the CI server.
Answers
My guess is that the version of nuget on the CI server is too old and so does not support generating an obj/project.assets.json file for your .NET Standard project. This file will contain the reference information required by msbuild.
Mono 5.2 ships with nuget 2.12. Whilst Mono 5.4 ships with NuGet 4.3. NuGet v2 does not support the newer project formats when running a restore.
Another alternative, if the project is an SDK style project, or uses PackageReferences, would be to use
msbuild /t:restore
to generate the project.assets.json file.I think the simplest solution here would be to update Mono on the CI server.
Hey @mattward, thanks for your response! That makes perfect sense. I had already pointed out the need for updating the CI machine, but wasn't sure if that would resolve the issue. I'm awaiting their confirmation that updating took care of it.
Thanks again for the answer, Matt, your suggestion took care of the issue.