Cannot run .net ef even though tooling installed - xamarin

I am trying to get ef core working within xamrian and I am having a few issues with the dotnet command not running. I have added the tools as per another so but that did not work.
This is my first migration and my conneciton stirng is set in the application.json of
"ConnectionStrings": {
"DefaultConnection": "Data Source=DEVELOPER\SAGESQL2014;Initial
Catalog=CallManagment;Integrated
Security=True;MultipleActiveResultSets=True" } }
This is the error I am getting thanks for the help.
dotnet ef migrations add InitialMigration dotnet : No executable found
matching command "dotnet-ef" At line:1 char:1
+ dotnet ef migrations add InitialMigration
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (No executable f...and "dotnet-ef":String) [], RemoteExcept ion
+ FullyQualifiedErrorId : NativeCommandErro
This is my project file at present
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<None Remove="appsettings.json" />
</ItemGroup>
<ItemGroup>
<Content Include="appsettings.json">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.2" />
</ItemGroup>
<ItemGroup>
<Reference Include="System">
<HintPath>System</HintPath>
</Reference>
</ItemGroup>
</Project>
EDIT 2 TO show assembles added.
Edit 3
To Show changes made from below suggestion still not working.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<None Remove="appsettings.json" />
</ItemGroup>
<ItemGroup>
<Content Include="appsettings.json">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.2" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.2" />
</ItemGroup>
<ItemGroup>
<Reference Include="System">
<HintPath>System</HintPath>
</Reference>
</ItemGroup>
</Project>

Are you trying to run inside Package Manager Console? If so you'll need to cd to the project directory. Also, if you're inside PMC, why aren't you using the EF Core PMC tools?

Related

Issues creating a nuget package referening Xamarin Forms

I'm creating a nuget package that is refercing a number of different packages for the platforms.
I don't sem to be able to reference Xam.Forms.Platform. from the various ItemGroups as well as packages I've added via nuget for specific platforms.
I'm using this as a reference : https://learn.microsoft.com/en-us/nuget/guides/create-packages-for-xamarin and my csproj is this
<Project Sdk="MSBuild.Sdk.Extras/2.0.54">
<PropertyGroup>
<!--Work around so the conditions work below-->
<TargetFrameworks></TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' ==
'Windows_NT'">netstandard2.0;Xamarin.iOS10;MonoAndroid90;uap10.0.16299</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' !=
'Windows_NT'">netstandard2.0;Xamarin.iOS10;MonoAndroid90</TargetFrameworks>
<AssemblyName>Plugin.Mobile.Xamarin</AssemblyName>
<RootNamespace>Plugin.Mobile.Xamarin</RootNamespace>
<PackageId>Plugin.Mobile.Xamarin</PackageId>
<Product>Plugin.Mobile.Xamarin</Product>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<AssemblyFileVersion>1.0.0.0</AssemblyFileVersion>
<Version>1.0.0.0</Version>
<PackageVersion>1.0.0.0</PackageVersion>
<PackOnBuild>true</PackOnBuild>
<NeutralLanguage>en</NeutralLanguage>
<LangVersion>default</LangVersion>
<DefineConstants>$(DefineConstants);</DefineConstants>
<UseFullSemVerForNuGet>false</UseFullSemVerForNuGet>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<LangVersion>latest</LangVersion>
<DebugType>portable</DebugType>
<PropertyGroup Condition=" '$(Configuration)'=='Debug' ">
<DebugSymbols>true</DebugSymbols>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)'=='Release' ">
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>
<Compile Include="**\*.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform" Version="6.2.10" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Xamarin.Essentials" Version="1.5.3.2" />
<PackageReference Include="Xamarin.Forms" Version="4.7.0.1179" />
<PackageReference Include="Xamarin.Forms.Visual.Material" Version="4.7.0.1179" />
<PackageReference Include="SkiaSharp.Views.Forms" Version="2.80.1" />
</ItemGroup>
<ItemGroup>
<None Update="Langs.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Langs.resx</DependentUpon>
</None>
</ItemGroup>
<ItemGroup>
<None Update="shared\Langs.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Langs.resx</DependentUpon>
</None>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="SkiaSharp.Views.Forms">
<Version>2.80.1</Version>
</PackageReference>
<PackageReference Include="Xamarin.Essentials" Version="1.5.3.2" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'uap10.0.16299'">
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform" Version="6.2.9" />
<Reference Include="Microsoft.CSharp" />
<PackageReference Include="SkiaSharp.Views.Forms">
<Version>2.80.1</Version>
</PackageReference>
<PackageReference Include="Xamarin.Forms" Version="4.7.0.1179" />
<PackageReference Include="Xamarin.Forms.Visual.Material" Version="4.7.0.1179" />
<SDKReference Include="WindowsMobile, Version=10.0.16299.0">
<Name>Windows Mobile Extensions for the UWP</Name>
</SDKReference>
<Compile Include="**\UWP*.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'Xamarin.iOS10'">
<Reference Include="Xamarin.iOS">
<HintPath>..\..\..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\Xamarin.iOS\v1.0\Xamarin.iOS.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<PackageReference Include="EasyTipView">
<Version>1.0.1</Version>
</PackageReference>
<PackageReference Include="SkiaSharp.Views.Forms">
<Version>2.80.1</Version>
</PackageReference>
<PackageReference Include="Xamarin.Forms" Version="4.7.0.1179" />
<PackageReference Include="Xamarin.Forms.Visual.Material" Version="4.7.0.1179" />
<Compile Include="**\iOS*.cs" />
</ItemGroup>
<ItemGroup Condition=" $(TargetFramework.StartsWith('MonoAndroid')) ">
<Reference Include="Mono.Android">
<HintPath>..\..\..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v9.0\Mono.Android.dll</HintPath>
</Reference>
<PackageReference Include="SkiaSharp.Views.Forms">
<Version>2.80.1</Version>
</PackageReference>
<PackageReference Include="Xamarin.Android.Tooltips">
<Version>1.0.7</Version>
</PackageReference>
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
<Reference Include="System.Numerics" />
<PackageReference Include="Xamarin.Forms" Version="4.7.0.1179" />
<PackageReference Include="Xamarin.Forms.Visual.Material" Version="4.7.0.1179" />
<Compile Include="**\Droid*.cs" />
</ItemGroup>
</Project>
Any ideas on why I can't include or reference these packages?
The errors I'm seeing are the likes of
Any ideas on why I can't include or reference these packages?
The issue is caused by the project template Cross-Platform .NET Standard Library Plugin.
To be precise, this is due to the design of this special project template.
As the document said, you should use the corresponding platform namespace in xxx.<PLATFORM>.cs file of each platform project.
Suggestion
From your description, the namespaces you are using are all related to Android, so you should add these in the file <project_name>.andoroid.cswhich targets to MonoAndroid90.
And if you input them in the file called apple.cs,uwp.cs or others, the template is unable to identify them.
And you can see <project_name>.andoroid.cs file is connected with MonoAndroid90, so it can identify android namespaces and the same is true for other platform files.
In addition, if you still want your requirements, you should connect with the extension's author to reflect the issue.
try to change your TargetFrameworks become like this
<TargetFrameworks>netstandard2.0;Xamarin.iOS10;MonoAndroid90</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">uap10.0.16299;$(TargetFrameworks)</TargetFrameworks>

F#: How to avoid "[FS0988] Main module of program is empty: nothing will happen when it is run" in Tests Project?

I have a .NET solution with the projects below:
Console: Console .NET Core 2.2
Domain: .NET Standard 2.0
Domain.Tests: Console .NET Core 2.2 (XUnit)
Infrastructure: .NET Standard 2.0
My Domain.Tests.fsproj is defined as:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<IsPackable>false</IsPackable>
<GenerateProgramFile>false</GenerateProgramFile>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FsCheck" Version="3.0.0-alpha4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
</ItemGroup>
<ItemGroup>
<Compile Include="Dsl.fs" />
<Compile Include="OpenAccountTests.fs" />
<Compile Include="CloseAccountTests.fs" />
<Compile Include="DepositCashTests.fs" />
<Compile Include="WithdrawCashTests.fs" />
<Compile Include="WireMoneyTests.fs" />
<Compile Include="RequestAddressChangeTests.fs" />
<Compile Include="RequestEmailChangeTests.fs" />
<Compile Include="RequestPhoneNumberChangeTests.fs" />
<Compile Include="ValidateAddressChangeTests.fs" />
<Compile Include="ValidateEmailChangeTests.fs" />
<Compile Include="ValidatePhoneNumberChangeTests.fs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Domain\Domain.fsproj" />
</ItemGroup>
</Project>
But when compiling the solution I have the following warning:
ValidatePhoneNumberChangeTests.fs(102, 35): [FS0988] Main module of program is empty: nothing will happen when it is run
I checked that answer on SO and adding do() at the end of the last file of Domain.Tests: ValidatePhoneNumberChangeTests.fs didn't do anything.
What can I do to get rid of this warning?
#rmunn is on the right track in the comments. <OutputType> defaults to Library when TargetFramework is netstandardXX or net4XX, and Exe when TargetFramework is netcoreappXX.
Setting <OutputType>Library</OutputType> is IMO the best way to fix this, rather than adding an entry point that won't be called.
<TargetFramework>netcoreapp2.2</TargetFramework>
This specifies the Domain.Tests project as an executable
If you only need it to be a class library then change it to
<TargetFramework>netstandard2.0</TargetFramework>
If you simply want to remove the warning you can add a main method by either adding this at the end of ValidatePhoneNumberChangeTests.fs or in a Program.fs at the end of the compilation order
[<EntryPoint>]
let main argv =
0
Just remove the Program.fs and OutputType (it doesn't work for me as well). Set GenerateProgramFile to true in PropertyGroup like that:
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<IsPackable>false</IsPackable>
<GenerateProgramFile>true</GenerateProgramFile>
</PropertyGroup>
cheers!

How to stop .net-core from continuously adding folders when building

Every time I build my .NET Core project, it adds a deeper folder containing the .csproj file in \bin\release. The result is the following folder structure:
D:\home>
D:\home\site>
D:\home\site\repository>
D:\home\site\repository\bin>
D:\home\site\repository\bin\Release>
D:\home\site\repository\bin\Release\netcoreapp2.1>
D:\home\site\repository\bin\Release\netcoreapp2.1\bin>
D:\home\site\repository\bin\Release\netcoreapp2.1\bin\Release>
D:\home\site\repository\bin\Release\netcoreapp2.1\bin\Release\netcoreapp2.1>
D:\home\site\repository\bin\Release\netcoreapp2.1\bin\Release\netcoreapp2.1\bin>
D:\home\site\repository\bin\Release\netcoreapp2.1\bin\Release\netcoreapp2.1\bin\Release>
D:\home\site\repository\bin\Release\netcoreapp2.1\bin\Release\netcoreapp2.1\bin\Release\netcoreapp2.1>
D:\home\site\repository\bin\Release\netcoreapp2.1\bin\Release\netcoreapp2.1\bin\Release\netcoreapp2.1\bin>
D:\home\site\repository\bin\Release\netcoreapp2.1\bin\Release\netcoreapp2.1\bin\Release\netcoreapp2.1\bin\Release>
This keeps on growing when more builds are executed.
In Visual Studio, cleaning and rebuilding helps solve it. After a few builds the filename becomes too long, raising an error when trying to run the application.
At first, it did not really matter, but when deploying the WebApp-Bot to Azure, the same happens. The problem is that I have no option to remove the excessive files from the server. Which is why I need to stop it from happening at all.
The .csproj file:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<UserSecretsId>SOME_USER_SECRETS_ID</UserSecretsId>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Compile Remove="%2a%2a\**" />
<Content Remove="%2a%2a\**" />
<EmbeddedResource Remove="%2a%2a\**" />
<None Remove="%2a%2a\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Gremlin.Net" Version="3.4.1" />
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.1.2" PrivateAssets="All" />
<PackageReference Include="Microsoft.Bot.Builder.AI.Luis" Version="4.4.3" />
<PackageReference Include="Microsoft.Bot.Builder.Dialogs" Version="4.4.3" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.AspNet.Core" Version="4.4.3" />
<PackageReference Include="Microsoft.Recognizers.Text.DataTypes.TimexExpression" Version="1.1.6" />
</ItemGroup>
<Import Project="PostDeployScripts\IncludeSources.targets" Condition="Exists('PostDeployScripts\IncludeSources.targets')" />
<Import Project="..\PostDeployScripts\IncludeSources.targets" Condition="Exists('..\PostDeployScripts\IncludeSources.targets')" />
<ItemGroup>
<None Remove="%2a%2a\%2a.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="bin\" />
</ItemGroup>
<ProjectExtensions><VisualStudio><UserProperties Properties_4launchSettings_1json__JSONSchema="" /></VisualStudio></ProjectExtensions>
</Project>
The includesources.targets, which I see now has the always flag:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Compile Update="**\*.cs">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Compile>
<None Include="**\*.csproj" >
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="PostDeployScripts\*.*" >
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
I would like to know why this happens and how to stop it, all help is welcome.
Your includesources.targets file has this little gem in it:
<Compile Update="**\*.cs">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Compile>
Which would, if I understand correctly, cause the .cs files to be copied to your output folder. The next time a build is triggered, these files will probably also be compiled, creating a new bin\Release\netcoreapp2.1 from that location.
I'm not entirely sure what the targets file is there for, but I am pretty sure it's causing this issue. Try removing the file and the references to it from your .csproj, rebuild your project and see if you can deploy the bot.

Error while trying to publish Azure Functions (v1) with VisualStudio 15.7.0 Preview 6.0

I am unable to publish my Azure Functions (v1) Project after upgraded to VisualStudio 15.7.0 Preview 6.0 I get this error when click Publish button
C:\Program
Files\dotnet\sdk\2.1.200-preview-007597\Sdks\Microsoft.NET.Sdk\build\Microsoft.PackageDependencyResolution.targets(167,5): error
: Assets file 'C:\Users\tonyv\source\repos\SistemaMulti\WebAPI\obj\project.assets.json'
doesn't have a target for '.NETFramework,Version=v4.6.1/win'. Ensure you have restored this project for TargetFrameworks 'net461'
Maybe you also need to include 'win' on RuntimeIdentifiers of yout project.
[C:\Users\tonyv\source\repos\SistemaMulti\WebAPI\WebAPI.csproj]
My .csproj is:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Remove="MercadoPago\Pessoa.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.13" />
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Folder Include="MercadoPago\" />
</ItemGroup>
</Project>
How to fix this?
The issue is that the following property is getting set in the publish profile (under Properties\Publish Profiles\<profilename>.pubxml)
<RuntimeIdentifier>win</RuntimeIdentifier>
Removing this property from the publishprofile should fix the issue.
There is a github thread for the same issue - https://github.com/Azure/Azure-Functions/issues/571
The workaround recommended there is:
Update this line in Properties\PublishProfiles\.pubxml (Remove the space in Any CPU).
<LastUsedPlatform>AnyCPU</LastUsedPlatform>
(Updating the profile from profile settings UI may re-add the space. Please remove it after any profile modification).

the runcommand property is not defined on ASP.NET Core 2

In Visual Studio 2017, I got an error in all projects that are related with ASP.NET Core 2 .
That says:
unable to run your project. the runcommand property is not defined
Even I uninstalled the VS and again installed it but I have still this problem.
I tested default project template for VS but those do not execute right, too.
Please help me.
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
<ApplicationIcon />
<OutputType>Library</OutputType>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Folder Include="Views\Product\" />
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.3" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.1" />
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
</ItemGroup>
</Project>
netcoreapp2.0
Try changing to:
netstandard2.0

Resources