[当我尝试使用Xamarin.Forms
建立更新的Jenkins
项目时,我遇到了类似的1500多个错误:
App.xaml.cs(24,32):错误CS0012:常规参考定义中的Der Typ“ Object” ist。 FügenSie einen Verweis auf die Assembly“ netstandard,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = cc7b13ffcd2ddd51” hinzu。
翻译错误:
CS0012:类型'System.Object'是在未引用的程序集中定义的。您必须添加对程序集'netstandard,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = cc7b13ffcd2ddd51'的引用。
如果我使用同一台机器构建项目,但在Visual Studio 2017
内,则可以正常工作(就像在我的本地机器上一样)。 Jenkins
的构建命令看起来像这样
"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
以前是我updated to .NET Standard 2.0
和.NET Standard 2.0
。构建服务器本身在Xamarin.Forms 3.4.0.1039999
Windows 10 1703
上运行。 我在(我Windows 10 1909
项目中有UWP
,但是我没有真正使用它。Xamarin.Forms
如果要与read一起使用Windows 10 1709
,则至少需要.NET Standard 2.0
]。)
该项目还引用了UWP
程序包,该程序包与NuGet
尚不兼容。我在这里得到警告
警告NU1701软件包'xxx'是使用'.NETFramework,Version = v4.6.1'而不是项目目标框架'.NETStandard,Version = v2.0'恢复的。该软件包可能与您的项目不完全兼容。
这可能是有些问题的原因,因为它是.NET Standard 2.0
。
我尝试过的事情:
bin
文件夹obj
的使用未成功与Jenkins建立关系。对<Reference Include="netstandard" />
的引用在我的本地构建环境中引发了警告(但已安装)NETStandard.Library
和Visual Studio Build Tools 2017
更新为最新版本(15.9.18)Visual Studio 2017
,.NET Core SDK
,.NET Core Build Tools
.NET Framework 4.7.2 SDK
环境变量,将全局环境变量PATH
设置为C:\ Program Files \ dotnet \ sdk \ 2.1.509 \ Sdks我观察到的内容:
MSBuildSDKsPath
在构建服务器上使用Visual Studio 2017
构建项目可以正常工作>>Windows 10 1703
在本地计算机上使用Visual Studio 2017
构建项目可以正常工作Windows 10 1809
和构建服务器上的命令行上构建项目可以正常工作(NuGet软件包正确引用了netstandard2.0而不是netstandard1.3等等,在NuGetFallbackFolder中依此类推)我可以尝试的方法:
msbuild
或更高版本Windows 10 1709
的库.NET 4.6.1
Visual Studio 2019
项目并复制所有文件(并丢失.NET Standard
历史记录]但是我没有得到的是它在GIT
中工作正常,但在Visual Studio
/ msbuild
中却不能正常工作。似乎缺少参考或未安装某些内容。
我该怎么办?
编辑:
从项目的Xamarin.Forms部分提取。csproj
Jenkins
[当我尝试使用Jenkins构建更新的Xamarin.Forms项目时,我遇到了1500多个错误:App.xaml.cs(24,32):错误CS0012:einer nicht referenzierten中的Der Typ“ Object” ist ...
我想我用这个解决了
<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>