[英]How to Remove local nuget references
Unload Project
。<ItemGroup>
。Reload
它。您已在非 sdk 網絡框架項目的 csproj 文件上添加了RuntimeIdentifier xml 節點。
這就是原因。 您應該注意, RuntimeIdentifier
適用於新的 sdk net core
跨平台項目,而不是您的非 sdk net framework
windows 項目。
RuntimeIdentifier
不適用於非 sdk 網絡框架項目。
所以你必須在csproj
文件中刪除這些。
<PropertyGroup>
<RuntimeIdentifier>osx-x64</RuntimeIdentifier>
</PropertyGroup>
當我刪除它時,一切正常。
問題在這里:
C:\Users\xxx\.nuget\packages\realm\10.1.1\build\Realm.props
然后打開那個文件,你會看到:
您有兩點需要注意:
1) NativeReference works for ios apps rather than android apps, actually, you could just delete the NativeReference
node but for the inclusiveness and comprehensiveness of the nuget package, it is not advisable to delete it.
2) NativeReference無法識別 MSBuild 屬性的值。 您不能在其中傳遞屬性值。 正如我的鏈接所暗示的那樣。
首先, itemgroup condition
在構建的時候確實會被vs根據條件進行處理,但是沒有構建的時候會忽略條件去檢查它的內容判斷是否有效,但是因為你的Android項目一直無法識別nativereference
,所以問題一直存在。
為了跳過這個檢測機制,你最好使用choose, when
。 而在這個場景中,你使用的是Android項目,所以不需要考慮nativereference
不能識別屬性的問題。
建議一
將Realm.props
修改為:
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<_RealmNugetNativePath Condition="'$(_RealmNugetNativePath)' == ''">$(MSBuildThisFileDirectory)..\native\</_RealmNugetNativePath>
</PropertyGroup>
<Choose>
<When Condition="'$(TargetFrameworkIdentifier)' == 'Xamarin.iOS'">
<ItemGroup>
<NativeReference Include="$(_RealmNugetNativePath)ios\universal\realm-wrappers.framework">
<Kind>Framework</Kind>
<SmartLink>False</SmartLink>
</NativeReference>
</ItemGroup>
</When>
<When Condition="'$(TargetFrameworkIdentifier)' == 'Xamarin.Mac'">
<ItemGroup>
<NativeReference Include="$(_RealmNugetNativePath)..\runtimes\osx-x64\native\librealm-wrappers.dylib">
<Kind>Dynamic</Kind>
</NativeReference>
</ItemGroup>
</When>
</Choose>
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == 'Xamarin.iOS'">
<Content Include="$(_RealmNugetNativePath)ios\Realm.dll.config">
<Link>Realm.dll.config</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == 'MonoAndroid'">
<AndroidNativeLibrary Include="$(_RealmNugetNativePath)android\armeabi-v7a\librealm-wrappers.so">
<Link>$(_RealmNugetNativePath)android\armeabi-v7a\librealm-wrappers.so</Link>
</AndroidNativeLibrary>
<AndroidNativeLibrary Include="$(_RealmNugetNativePath)android\x86\librealm-wrappers.so">
<Link>$(_RealmNugetNativePath)android\x86\librealm-wrappers.so</Link>
</AndroidNativeLibrary>
<!-- 64bit -->
<AndroidNativeLibrary Include="$(_RealmNugetNativePath)android\arm64-v8a\librealm-wrappers.so">
<Link>$(_RealmNugetNativePath)android\arm64-v8a\librealm-wrappers.so</Link>
</AndroidNativeLibrary>
<AndroidNativeLibrary Include="$(_RealmNugetNativePath)android\x86_64\librealm-wrappers.so">
<Link>$(_RealmNugetNativePath)android\x86_64\librealm-wrappers.so</Link>
</AndroidNativeLibrary>
</ItemGroup>
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
<None Include="$(_RealmNugetNativePath)..\runtimes\win-x86\native\realm-wrappers.dll">
<Link>lib\win32\x86\realm-wrappers.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(_RealmNugetNativePath)..\runtimes\win-x64\native\realm-wrappers.dll">
<Link>lib\win32\x64\realm-wrappers.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
建議二
2)如果您進一步使用 IOS 應用程序,您必須嘗試這些:
a)刪除Realm.props
文件下的兩個NativeReference
節點
b)然后將這些添加到ios.csoroj
文件中:
<Choose>
<When Condition="'$(TargetFrameworkIdentifier)' == 'Xamarin.iOS'">
<ItemGroup>
<NativeReference Include="C:\Users\xxx\.nuget\packages\realm\10.1.1\native\ios\universal\realm-wrappers.framework" Kind="Framework" SmartLink="False">
</NativeReference>
</ItemGroup>
</When>
<When Condition="'$(TargetFrameworkIdentifier)' == 'Xamarin.Mac'">
<ItemGroup>
<NativeReference Include="C:\Users\xxx\.nuget\packages\realm\10.1.1\runtimes\osx-x64\native\librealm-wrappers.dylib" Kind="Dynamic">
</NativeReference>
</ItemGroup>
</When>
</Choose>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.