I'm getting over 1500 errors like this, when I try to build an updated Xamarin.Forms
project with Jenkins
:
App.xaml.cs(24,32): error CS0012: Der Typ "Object" ist in einer nicht referenzierten Assembly definiert. Fügen Sie einen Verweis auf die Assembly "netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" hinzu.
Translated error:
CS0012: The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
If I build the project with the same machine, but within Visual Studio 2017
it works without problems (as on my local machine). The build command for Jenkins
looks like this
"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild" /p:ReferencePath=C:\jenkins\workspace\somelibrary\ SomeProject/SomeProject/SomeProject.csproj /t:Restore /p:Configuration=Release /t:Build
Previously I updated to .NET Standard 2.0
and Xamarin.Forms 3.4.0.1039999
. The build server itself is running on Windows 10 1703
Windows 10 1909
. I have (I read that you need at least UWP
in my Xamarin.Forms
project, but I'm not really using it.Windows 10 1709
if you want to use .NET Standard 2.0
together with UWP
.)
The project is also referencing a NuGet
package, which isn't compatible with .NET Standard 2.0
yet. Here I get the warning
Warning NU1701 Package 'xxx' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project.
This could be a reason why there are some problems, because it is not fully compatible.
What I tried:
- clean build, deleted
bin
andobj
folder - use of
<Reference Include="netstandard" />
without success at building with Jenkins. Reference toNETStandard.Library
throws a warning in my local build environment (but it is installed) - updated
Visual Studio Build Tools 2017
andVisual Studio 2017
to the latest version (15.9.18) - installed
.NET Core SDK
,.NET Core Build Tools
,.NET Framework 4.7.2 SDK
on the build server - extended
PATH
environment variable with C:\Program Files\dotnet, set global environment variableMSBuildSDKsPath
to C:\Program Files\dotnet\sdk\2.1.509\Sdks - deleted UWP project (still exists on folder, but not in *.sln)
- made some research after similar problems from other users, but didn't find something that solved the issue
What I observed:
- building the project works fine with
Visual Studio 2017
on the build server withWindows 10 1703
- building the project works fine with
Visual Studio 2017
on my local machine withWindows 10 1809
- building the project works fine with
msbuild
and command line on the build server (NuGet packages references correctly netstandard2.0 instead of netstandard1.3 and so on in the NuGetFallbackFolder)
What I could try:
update the build server toWindows 10 1709
or higher- replace/update the library, which still uses
.NET 4.6.1
- upgrade to
Visual Studio 2019
- create a
.NET Standard
project from scratch and copy all files over (and loosingGIT
history)
But what I don't get is that it is working fine in Visual Studio
but not with msbuild
/Jenkins
. Seems that a reference is missing or something is not installed.
What should I do?
Edit:
Extract of the .csproj from the Xamarin.Forms part of the project
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<NeutralLanguage>en</NeutralLanguage>
<AssemblySearchPaths>
$(AssemblySearchPaths);
$(ReferencePath);
</AssemblySearchPaths>
</PropertyGroup>
<ItemGroup>
<None Remove="picture.png" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Plugin" Version="5.2.0" />
</ItemGroup>
<ItemGroup>
<Reference Include="SomeLibrary">
<HintPath>pat\to\library\netstandard2.0\SomeLibrary.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Update="Common\Localization\AppResources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>AppResources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Common\Localization\AppResources.de.resx">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Update="Common\Localization\AppResources.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>AppResources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Update="App.xaml">
<Generator>MSBuild:Compile</Generator>
</None>
<None Update="SomePage.xaml">
<Generator>MSBuild:Compile</Generator>
</None>
</ItemGroup>
</Project>
csproj
file? – Pavel AnikhouskiWarning NU1701
error? Also, how did you restore the packages and build the sources, which commands are used? Also this thread might be helpful – Pavel Anikhouskimsbuild
and/t:Restore
as shown above. There are multiple things in the build process involved. The main part consists of building the Xamarin.Forms project first withmsbuild /p:ReferencePath=xxx SomeProject/SomeProject/SomeProject.csproj /t:Restore /p:Configuration=Release /t:Build
and then the Android project withmsbuild /p:ReferencePath=xxx SomeProject/SomeProject.Droid/SomeProject.Droid.csproj /p:Configuration=Release /t:Restore /t:PackageForAndroid /t:Build
. But he get's the errors at the first step – testingPATH
environment variable is pointing toC:\Program Files\dotnet
on the build server. – testing