'Build error: Reference PresentationCore could not be resolved
I have a WPF C# application hosted on GitHub attached to Travis. I configured my .travis-ci.yml this way:
language: csharp
solution: FaceDetection/FaceDetection.sln
script:
- xbuild /p:Configuration=Debug /p:Platform=x86 /p:TargetFrameworkVersion="v4.0" FaceDetection/FaceDetection.sln
However I get these errors when the project is about to compile by travis:
/usr/lib/mono/4.5/Microsoft.Common.targets: warning : Reference 'PresentationCore' not resolved
/usr/lib/mono/4.5/Microsoft.Common.targets: warning : Reference 'PresentationFramework' not resolved
Compiling the project locally on my windows machine in VS works fine. Therefore I included all needed references for the project.
This happens to some more references too:
Views/Converters/BitmapConverter.cs(5,28): error CS0234: The type or namespace name `Imaging' does not exist in the namespace `System.Windows.Media'. Are you missing an assembly reference?
Views/UserControls/FaceDatabaseEntry.xaml.cs(7,22): error CS0234: The type or namespace name `Controls' does not exist in the namespace `System.Windows'. Are you missing an assembly reference?
Views/UserControls/FaceDatabaseEntry.xaml.cs(9,22): error CS0234: The type or namespace name `Documents' does not exist in the namespace `System.Windows'. Are you missing an assembly reference?
Views/UserControls/FaceDatabaseEntry.xaml.cs(12,28): error CS0234: The type or namespace name `Imaging' does not exist in the namespace `System.Windows.Media'. Are you missing an assembly reference?
Views/UserControls/FaceDatabaseEntry.xaml.cs(13,22): error CS0234: The type or namespace name `Navigation' does not exist in the namespace `System.Windows'. Are you missing an assembly reference?
Views/UserControls/FaceDatabaseEntry.xaml.cs(14,22): error CS0234: The type or namespace name `Shapes' does not exist in the namespace `System.Windows'. Are you missing an assembly reference?
ViewModel/AddFaceViewModel.cs(13,38): error CS0012: The type `System.ComponentModel.INotifyPropertyChanged' is defined in an assembly that is not referenced. Consider adding a reference to assembly `System.ObjectModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
The needed packages are restored fine before it is about to compile:
Installing 'PostSharp.Patterns.Model 4.2.27'.
Installing 'System.Data.SQLite.Linq 1.0.101.0'.
Installing 'PostSharp.Patterns.Common 4.2.27'.
Installing 'ZedGraph 5.1.7'.
Installing 'MahApps.Metro 1.3.0-ALPHA160'.
Installing 'MvvmLight 5.3.0.0'.
Installing 'DirectShowLib 1.0.0'.
Installing 'System.Data.SQLite.Core 1.0.101.0'.
Installing 'CommonServiceLocator 1.3'.
Installing 'System.Data.SQLite.EF6 1.0.101.0'.
Installing 'PostSharp 4.2.27'.
Installing 'System.Data.SQLite 1.0.101.0'.
Installing 'OpenTK 1.1.2349.61993'.
Installing 'EmguCV 3.1.0'.
Installing 'OpenTK.GLControl 1.1.2349.61993'.
Installing 'EntityFramework 6.1.3'.
Successfully installed 'PostSharp.Patterns.Model 4.2.27'.
Successfully installed 'PostSharp.Patterns.Common 4.2.27'.
Successfully installed 'DirectShowLib 1.0.0'.
Successfully installed 'MvvmLight 5.3.0.0'.
Successfully installed 'ZedGraph 5.1.7'.
Successfully installed 'CommonServiceLocator 1.3'.
Successfully installed 'OpenTK 1.1.2349.61993'.
Successfully installed 'System.Data.SQLite.Linq 1.0.101.0'.
Successfully installed 'PostSharp 4.2.27'.
Successfully installed 'System.Data.SQLite 1.0.101.0'.
Successfully installed 'OpenTK.GLControl 1.1.2349.61993'.
Successfully installed 'System.Data.SQLite.EF6 1.0.101.0'.
Successfully installed 'EntityFramework 6.1.3'.
Successfully installed 'MahApps.Metro 1.3.0-ALPHA160'.
Successfully installed 'MvvmLightLibs 5.3.0.0'.
Successfully installed 'System.Data.SQLite.Core 1.0.101.0'.
Successfully installed 'EmguCV 3.1.0'.
The versions of mono and xbuild:
$ mono --version
Mono JIT compiler version 4.2.3 (Stable 4.2.3.4/832de4b Wed Mar 16 13:19:08 UTC 2016)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: amd64
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: sgen
$ xbuild /version
XBuild Engine Version 12.0
Mono, Version 4.2.3.0
Copyright (C) 2005-2013 Various Mono authors
Solution 1:[1]
Basically, WPF isn't supported by Mono (or .NET running on any platform other than Windows).
You'll need to find a Windows-based CI service such as AppVeyor instead.
Solution 2:[2]
We came across similar problem as well. However, the error message says explicitly what's missing:
/usr/lib/mono/4.5/Microsoft.Common.targets: warning : Reference 'PresentationCore' not resolved
/usr/lib/mono/4.5/Microsoft.Common.targets: warning : Reference 'PresentationFramework' not resolved
You can take the corresponding PresentationCore.dll and PresentationFramework.dll from your system and copy to your project e.g. from a folder like that depends on your NET Version:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2
Then you can explicitly add the references to these DLLs to your project. The corresponding csproj file should have afterwards some references that look like the following:
<Reference Include="PresentationCore">
<HintPath>/builds/dll_references/PresentationCore.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="PresentationFramework">
<HintPath>/builds/dll_references/PresentationFramework.dll</HintPath>
<Private>False</Private>
</Reference>
Again the paths will depend on your project structure. And yes, afterwards the project can be built successfully.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Jon Skeet |
Solution 2 | Fedor Petrov |