Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to migrate in .netstandard with Xamarin.Forms package ? #8336

Closed
paradisehuman opened this issue Apr 29, 2017 · 9 comments
Closed

Comments

@paradisehuman
Copy link

paradisehuman commented Apr 29, 2017

Hi.
I have a .netstandard Model layer that referenced from Xamarin.forms
I set Xamarin.Forms package in Model layer => PrivateAssets="All"
My .netstandard Data layer referenced from Model layer.
When I run this command in PowerShell :

dotnet ef --startup-project ../Eela.Web/ migrations add v1

I have this error :

C:\Users*.nuget\packages\xamarin.forms\2.3.4.231\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets(40,3): error MSB4062: The "Xamarin.Forms.Build.Tasks.FixedCreateCSharpManifestResourceName" task could not be loaded from the assembly C:\Users*.nuget\packages\xamarin.forms\2.3.4.231\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.Build.Tasks.dll. Could not load file or assembly 'Microsoft.Build.Utilities.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. [.....\Eela.Model.csproj]

Even I'm using :
<PackageTargetFallback>$(PackageTargetFallback);portable-win+net45+wp8+win81+wpa8</PackageTargetFallback>
in Data layer but the problem is persisted,

Is there any way to resolve this problem ?

@bricelam
Copy link
Contributor

bricelam commented May 1, 2017

What does your *.csproj file look like?

@bricelam
Copy link
Contributor

bricelam commented May 1, 2017

Also, have you tried installing the Microsoft.EntityFrameworkCore.Tools package and using the Add-Migration PMC command?

@paradisehuman
Copy link
Author

paradisehuman commented May 1, 2017

@bricelam
Data layer :

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup Label="Globals">
    <SccProjectName>SAK</SccProjectName>
    <SccProvider>SAK</SccProvider>
    <SccAuxPath>SAK</SccAuxPath>
    <SccLocalPath>SAK</SccLocalPath>
  </PropertyGroup>

  <PropertyGroup>
    <TargetFramework>netstandard1.6</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="1.1.1" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.1" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.1" />
  </ItemGroup>
  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\Eela.Model\Eela.Model.csproj" />
  </ItemGroup>

</Project>

I solved it by removing Xamarin.Forms dependency,
In fact I wanted the Command.cs class in Xamarin.Forms ,and I got the Command.cs source and copy paste it t to my code and I used it.

No i didn't use Add-Migration. I will test it . thanks any way.

@bricelam
Copy link
Contributor

bricelam commented May 1, 2017

Oh good. I'm glad you were able to solve it. It looks like the Xamarin.Forms package uses some MSBuild tasks that are incompatible with the dotnet command.

@bricelam
Copy link
Contributor

bricelam commented May 1, 2017

You could probably work around it by updating the reference to look like this:

<PackageReferecne Include="Xamarin.Forms" Version="2.3.4.231">
  <ExcludeAssets>build</ExcludeAssets>
</PackageReference>

@paradisehuman
Copy link
Author

paradisehuman commented May 1, 2017

@bricelam Thanks . I will test it ...
does Add-Migration use MSBuild ?

@bricelam
Copy link
Contributor

bricelam commented May 1, 2017

Not directly; it uses the Visual Studio APIs instead.

@paradisehuman
Copy link
Author

paradisehuman commented May 1, 2017

@bricelam

<PackageReferecne Include="Xamarin.Forms" Version="2.3.4.231">
  <ExcludeAssets>build</ExcludeAssets>
</PackageReference>

It worked like a charm ... Thank you ...

@paradisehuman
Copy link
Author

@bricelam We have a proverb in Persian that says : "Nosh daro bad az marge Sohrab"
It means : eating drug to someone after his death .
But it will help me in future work probably.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants