VS 15.3标准库不连接xaml和xaml.cs

时间:2017-08-16 08:35:45

标签: xaml xamarin .net-standard

昨天我对VS(15.3),.NET Standard 2.0,.NET Core SDK 2.0等进行了更新。之后,我当前的Xamarin Forms项目破产了。大多数软件包都失去了兼容性(虽然我没有更改库的standard1.4版本)。所以我通过VS创建了一个新的standard1.4库(如下所述:https://xamarinhelp.com/visual-studio-2017-net-standard-xamarin/)。我将旧Xamarin库中的代码复制到新库中并添加了所有包。

现在的问题是所有的xaml和xaml.cs都被拆分了,我得到了编译错误。我不能像以前那样连接文件(How can I connect xaml and xaml.cs files),因为csproj已经通过netstandard的演变完全改变了。更令人惊讶的是,即使我向项目添加了新的xaml页面,xaml和xaml.cs文件也会被拆分。我该如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

通过Microsoft Developer Network(https://developercommunity.visualstudio.com/content/problem/96027/vs-153-netstandard-xaml-and-xamlcs-seperated-and-c.html

上的帖子找到解决方案

归功于Long Nguyen(见来源):
通过以下文章修复它: https://oren.codes/2017/04/23/using-xamarin-forms-with-net-standard-vs-2017-edition/

在.csproj文件中,您可以看到他声明.xaml页面:

<ItemGroup>
  <!-- <a href="https://bugzilla.xamarin.com/show_bug.cgi?id=55591">https://bugzilla.xamarin.com/show_bug.cgi?id=55591</a> -->
  <None Remove="***.xaml" />
  <Compile Update="***.xaml.cs" DependentUpon="%(Filename)" />
  <EmbeddedResource Include="***.xaml" SubType="Designer" Generator="MSBuild:UpdateDesignTimeXaml" />
</ItemGroup>

在对csproj进行更改后,它应该再次获取xaml和xaml.cs文件。