2016-07-26 39 views
1

所以我一直在嘗試做一個項目,將使用netstandard類庫通用代碼,但是我一直不成功,因爲我一直在遇到錯誤。我一直在關注如何在這裏發佈https://oren.codes/2016/07/09/using-xamarin-forms-with-net-standard/https://xamarinhelp.com/dot-net-standard-pcl-xamarin-forms/。他的示例我可以下載並運行良好,但是當我嘗試使用他的指令複製它時,我遇到了錯誤錯誤,當試圖與Xamarin形式使用netstandard

您的項目未引用「.NETPortable,Version = v4.5,Profile = Profile111」框架。在project.json的「frameworks」部分中添加對「.NETPortable,Version = v4.5,Profile = Profile111」的引用,然後重新運行NuGet恢復。 FixMyCity.Mobile C:\ Program Files(x86)\ MSBuild \ Microsoft \ NuGet \ Microsoft.NuGet.targets 140

我知道這聽起來很明顯;只需添加.NETPortable,Version=v4.5,Profile=Profile111在project.json的框架部分,但後來我得到這個錯誤(80%肯定它是由在加入它,因爲它不存在以其他方式)

包含的MSBuild目標的軟件包和道具文件無法完全安裝在針對多個框架的項目中。 MSBuild目標和道具文件已被忽略。 ... project.nuget.targets

而且當我在看樣品的項目,他不針對.NETPortable,Version=v4.5,Profile=Profile111,它工作正常

這是我與它到目前爲止,如果你得到的最接近想看看:https://github.com/Toxicable/XamarinFormsNetstandardIssue
這只是模板項目(Xamrin形式protalble)與步驟下方施加

  1. 運行`PM>卸載,包裝xamarin.forms -Force -RemoveDependencies在每個項目上; IOS和Andriod首先是PCL。
  2. 重啓VS通過控制檯提示
  3. 添加在project.json每個項目如下
  4. 嘗試構建,但也它不會

PCL project.json

{ 
    "supports": {}, 
    "dependencies": { 
    "Xamarin.Forms": "2.3.0.107", 
    "NETStandard.Library": "1.6.0" 
    }, 
    "frameworks": { 
    "netstandard1.1": { 
     "imports": "portable-net45+win8+wpa81+wp8" 
    }, 
    ".NETPortable,Version=v4.5,Profile=Profile111": {} 
    } 
} 

項目.Driod project.json

{ 
    "dependencies": { 
    }, 
    "frameworks": { 
    "MonoAndroid,Version=v6.0": { 
    } 
    }, 
    "runtimes": { 
    "win": {} 
    } 
} 

project.iOS project.json

{ 
    "dependencies": { 
    }, 
    "frameworks": { 
    "Xamarin.iOS,Version=v1.0": { 
    } 
    }, 
    "runtimes": { 
    "win": {} 
    } 
} 
+0

你見過票據參考1? https://releases.xamarin.com/beta-release-cycle-7-service-release-1-updated/ 這些構建引入了與新的.NET標準1.6的兼容性。這尤其允許開發人員使用已針對.NET Standard 1.6構建的NuGet包。 –

+0

@JonDouglas我已經看到,我不確定與我的問題有什麼關係,即時通訊瞄準低網絡標準,因爲它是最兼容的,但會改變到我能夠瞄準iOS和Andriod的最高水平,我認爲這是1.6一旦項目真正建立起來 – Toxicable

回答

1

我下載了你的項目,並注意到,Xamarin窗體移植庫一直在尋找一個有點古怪,你通常會看到Xamarin形式和.NET標準庫在你的藍色圖標引用中。

我不知道它是如何發生的,但是這裏是你如何解決它。

  1. 從您的project.json中刪除".NETPortable,Version=v4.5,Profile=Profile111": {}

  2. 卸載項目

  3. 編輯項目文件

enter image description here

  • 刪除此行<TargetFrameworkProfile>Profile111</TargetFrameworkProfile>

  • 變化V4 .5至v5.0 <TargetFrameworkVersion>v5.0</TargetFrameworkVersion>

  • 保存文件並重新加載項目,現在建立無需Profile111,也將顯示在週期7服務發佈

  • enter image description here

    +0

    這正是問題所在,非常感謝您抽出時間指出這一點,也不確定它是如何發生的,但我希望任何有此問題的人都可以在此找到答案 – Toxicable