error CS0227: Unsafe code may only appear if compiling with /unsafe
。请尝试从.sln
文件进行构建,以便您的PCL配置得到支持,或者将启用unsafe
的Release|iPhone
(或您正在尝试构建的配置)配置添加到PCL/.NET标准项目中。原因是:在从.csproj
文件构建时,msbuild
期望所有引用的项目具有相同的配置名称,因为通常在PCL项目中没有*|iPhone
部分,所以无法知道如何将iOS项目配置Release|iPhone
映射到PCL项目中的配置。文档参考-https://learn.microsoft.com/en-us/appcenter/build/xamarin/ios/#312-building-from-the-project-file-csprojfsproj。
msbuild
调用时,没有传递/unsafe
开关。[command]/Library/Frameworks/Mono.framework/Versions/5_4_1/bin/msbuild /Users/vsts/agent/2.127.0/work/1/s/ios-xamarin/App.csproj /p:Configuration=Release /p:Platform=iPhoneSimulator /t:Rebuild
也许不支持/unsafe
开关? - LucaAllowUnsafeBlocks
属性将其传递给编译器。如果此属性在任何带有可能影响构建的Condition
属性的元素下定义,请检查 csproj 文件。 - Martin Ullrich/p:Configuration=Release
。 - Martin Ullrichmsbuild
正在使用.csproj
内容将事物传递给csc
。我之前并不知道这一点。当我说本地时,我是指在我的本地机器上构建。这个本地构建从Visual Studio和通过终端使用msbuild
都可以成功。即使使用/p:Configuration=Release
参数也是如此。 - Luca