dotnet run - looking for Microsoft.NETCore.App 1.1.0 (not preview) - I never refer to it - .net-core

I have a fairly in-depth project setup with 10-20 libraries, and I'm trying to build an executable which uses them.
I have .NET Core 1.1.0 preview1 installed. With new projects, everything works fine. dotnet restore and dotnet build also work fine for this project, but somewhere along the line, something is wrong, and it will not run.
dotnet run yields:
The specified framework 'Microsoft.NETCore.App', version '1.1.0' was not found.
- Check application dependencies and target a framework version installed at:
C:\Program Files\dotnet\shared\Microsoft.NETCore.App
- The following versions are installed:
1.0.1
1.1.0-preview1-001100-00
- Alternatively, install the framework version '1.1.0'.
My library projects have:
"frameworks": {
"netstandard1.6": {
"dependencies": {
"NETStandard.Library": "1.6.1-preview1-*"
}
}
}
My executable project has:
"frameworks": {
"netcoreapp1.1": {
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.1.0-preview1-*",
"type": "platform"
}
},
"imports": [ "dnxcore50", "portable-net45+win8" ]
}
}
It does also reference another project which is set up with an entry point, whose frameworks section is identical, minus the imports section.
I've also updated any EF Core and ASP.NET Core references to their preview1-* versions, though I am using plenty of other dependencies too (which weren't versioned in the same way).
So, as you can see, I have 1.1.0-preview1-001100-00 installed, am not referencing 1.1.0 anywhere, and yet receiving this message looking for it.
What could be causing this, and/or how can I track it down? I've tried scouring project.json.lock files, but can't see any references to 1.1.0 there, with the exception of an entry for Microsoft.NETCore.App/1.1.0 under libraries and again under the ".NETCoreApp,Version=v1.1" part of targets.

Wildcards aren't appropriate and don't work for this kind of platform dependency.
It's necessary to use
"version": "1.1.0-preview1-001100-00"
and not
"version": "1.1.0-preview1-*"

I have faced with the same problem deploying on Heroku instance. In may case during deployment the latest build is used (https://github.com/sass/node-sass/releases/download/v3.10.1/linux-x64-46_binding.node).
As a workaround it works if change
"Microsoft.NETCore.App": {
"version": "1.1.0-preview1-*",
to
"Microsoft.NETCore.App": {
"version": "1.1.0",
but on the other hand, it stops to work on local machine in this case...

Related

How to develop a composer app with external lib projects?

With Symfony 5, I am developing an application, with bundles. Each bundle have its own repository.
In dev (local) environnement, I want my app composer, takes package via symlink, and on production , from git repositories:
{
"type": "path",
"url": "../common",
"options": {
"symlink": true
}
},
{
"type": "vcs",
"url": "https://gitlab.bewizyu.com/XXX/common"
}
What the best practice for that?
The best practice is to have a local app as similar to production as possible.
Why can't you simply install your bundles from git repositories all the time? You develop a bundle, tag new version and update your main application and you are 100% sure it is the same as production.
With the symlinks, you can face a situation when production crashes and local works because there is a different setup.

EF Core Error - No project was found. Change the current working directory or use the --project option

I am using Visual Studio 2015 and dotnet core and trying to develop an EF Core Code First project using Sqlite and this documentation / tutorial, which also uses Sqlite => NET Core - New Database
When I try to add an initial migration from the command line ( I am CD-ed into the folder that my data model project is located in) by issuing the following command
dotnet ef migrations add InitialMigration
...I get the following Error.
No project was found. Change the current working directory or use the --project option.
I even tried using the --project option like so.
> dotnet --project "C:\Shiva\EF\EFCFSqlite.Data.xproj" ef migrations add InitialMigration
but that gives the following error.
Unknown option: --project
.NET Command Line Tools (1.0.0-preview2-003131)
Usage: dotnet [host-options] [command] [arguments] [common-options]
I noticed that the documentation is using .csproj file whereas my Project is showing a xproj file. Also the docs mention something about not using project.json anymore :(
Here's my project.json file.
{
"version": "1.0.0-*",
"dependencies": {
"Microsoft.EntityFrameworkCore.Sqlite": "1.1.1",
"Microsoft.EntityFrameworkCore.Sqlite.Design": "1.1.1",
"NETStandard.Library": "1.6.1"
},
"tools": {
"Microsoft.EntityFrameworkCore.Tools.DotNet":"1.0.0"
},
"frameworks": {
"netstandard1.6": {
"imports": "dnxcore50"
}
}
What has changed? Do we have no choice but to Install Visual Studio 2017 and start from scratch?? Is project.json and all this other stuff no longer honored?
Seems like a massive change to me if that's the case :(
sometimes you need to change the current directory in console/terminal eg:
PM> cd E:\Projects\CrossTest\
PM> dotnet ef migrations add InitialMigration
and
Align your package versions.
Either use preview1 packages or preview2.
Mix of those are not supported.
It simply Means that
YOU ARE NOT IN CURRENT PROJECT DIRECTORY
I was facing the same issue when scaffolding existing database of MySql using this.
Command I was executing:
dotnet ef dbcontext scaffold "Server=123.1.1.1;Uid=abc;Pwd=abc;Database=myDB;Connection Timeout=20;Persist Security Info=False;Port=3306;Allow User Variables=True;Connect Timeout=120;" MySql.Data.EntityFrameworkCore -o Models
Causing the same error , then I checked current working directory inside package manager console and found incorrect.
In my case
Mean I was not in current project directory then after switching directory
cd SSGCApp
Now you are in project directory all good to run the Command.
Instead of:
"tools": {
"Microsoft.EntityFrameworkCore.Tools.DotNet":"1.0.0"
},
try:
"tools": {
"Microsoft.EntityFrameworkCore.Tools.DotNet": {
"version": "1.0.0-preview3-final"
}},
Add the nuget package Microsoft.EntityFrameworkCore.Tools
Add the nuget package Microsoft.EntityFrameworkCore.Design
Right-click your project file, select Edit and then add the following to the ItemGroup that contains PackageReference nodes
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.3" />
(You can find the latest version by finding it in the Nuget Package manager)
Open the Package Manage Console: Tools->Nuget Package Manager->Package Manager Console
Type cd {path where your csproj file resides} (this is important)
Now type dotnet ef migrations add InitialMigration
Just faced similar issue. Fixed by downgrading to 1.0.0-preview3-final
"tools": {
"Microsoft.EntityFrameworkCore.Tools.DotNet": "1.0.0-preview3-final",
}
and changing --project param to --startup-project
dotnet ef --startup-project <PATH_TO_PROJECT_DIRECTORY> migrations add <MIGRATION_NAME>
In global.json I also downgraded version to
"sdk": {
"version": "1.0.0-preview2-003131"
}
This might be a temp workaround before migrating to csproj.
Apparently, it may sound funny, but in my case when I was getting this error I had the server-side of the app running. Basically, make sure that your app is not running at all when trying to create migrations. As I said, for me that was the cure. Might be a bit of advice for those who couldn't fix it by following the marked answer.
Just simply use this command.
Add-Migration InitialCreated -c bodoContext
No need to worry.
The dotnet-ef command has moved.
You will need to add a reference to
Microsoft.EntityFrameworkCore.Tools.DotNet AND
Microsoft.EntityFrameworkCore.Design to your dependencies in
project.json, then add Microsoft.EntityFrameworkCore.Tools.DotNet to the tools section and you should be good to go.
Cited from: http://errummwelluhh.blogspot.com
Add references Microsoft.EntityFrameworkCore.Design and Microsoft.EntityFrameworkCore.Tools
Then run:
dotnet-ef migrations add InitialCreate --project ProjectName
or
dotnet ef migrations add InitialCreate --project ProjectName

System.Net.Http Dependency Mismatch between Nuget package and ASP.NET Core app

Background
I'm trying to write some middleware to do custom authentication with ASP.NET Core. Because I'm dependent on some proprietary code using .NET framework, I'm using the .Net Framework version of ASP.NET Core rather than the .NET Core version of ASP.NET Core.
Initially, I built the middleware directly into an ASP.NET Core app and installed my proprietary dependencies with Nuget. This worked just fine.
Next, I wanted to build a Nuget package so that my middleware could be shared internally by several ASP.NET Core web services. So I created a class library and added the middleware code. I installed various ASP.NET Core Nuget Packages and my proprietary Nuget packages to resolve dependencies and built the Nuget Package. I installed it in an ASP.NET Core app successfully.
The Problem
When I try to run the middleware, I get the following: Could not load file or assembly 'System.Net.Http, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
The ASP.NET Core app seems to use System.Net.Http 4.0.0
Attempt 1
Naturally, I looked at the class library for its System.Net.Http dependency. It was pulled down in a Nuget package, appropriately named System.Net.Http. I installed that package to the ASP.NET Core app successfully (or so it told me). I ran the app and the middleware failed with the same error. Confused, I went back and looked at the Nuget packages. System.Net.Http was missing! I installed it again "successfully", but searching for the package again showed it wasn't installed.
I disabled automatic package restoration, I cleared the Nuget cache, and tried again. No luck. The package thinks it's successfully installed, but it never really works.
Here's the relevant section of the ASP.NET Core app's project.json:
{
"dependencies": {
"ProprietaryLibrary": "1.0",
"Microsoft.AspNetCore.Authentication": "1.1.0",
"Microsoft.AspNetCore.Mvc": "1.1.1",
"Microsoft.AspNetCore.Routing": "1.1.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0",
"Microsoft.Extensions.Configuration.FileExtensions": "1.1.0",
"Microsoft.Extensions.Configuration.Json": "1.1.0",
"Microsoft.Extensions.Logging": "1.1.0",
"Microsoft.Extensions.Logging.Console": "1.1.0",
"Microsoft.Extensions.Logging.Debug": "1.1.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0",
"MyMiddlewarePackage": "1.0.0",
"ProprietaryDependency": "1.0.0",
"ProprietaryDependency": "1.0.0",
"System.Net.Http": "4.0.0" <--- This updates to 4.1.0 if I install that nuget package, but nothing really happens.
},
"frameworks": {
"net461": { }
}
}
Attempt 2
It occurred to me that I may have set up the class library incorrectly. So I went to https://github.com/aspnet/Security and copied the project structure of their middleware. I again installed my dependencies (a much smaller list!), and it built successfully. I again built a Nuget package and installed it to the ASP.NET Core app. But again, I got the same error about Version 4.1.1.0.
Here is the project.json of the new class library:
{
"dependencies": {
"Microsoft.AspNetCore.Authentication": "1.0.0",
"Microsoft.Extensions.Caching.Memory": "1.0.0",
"Microsoft.Extensions.Options": "1.0.0",
"Microsoft.Extensions.WebEncoders": "1.0.0"
},
"frameworks": {
"net461": {
"dependencies": {
"ProprietaryLibrary": "1.0.0"
}
}
}
}
Nothing references System.Net.Http at all!
If you're curious about that proprietary library, here's the reference tree. All the blanked out stuff is proprietary DLLs. So I don't see any System.Net.Http reference there, either. I'm not saying it's not there, but I can't see it. And even if it was there, why would that proprietary library work just fine directly embedded in the ASP.NET Core app?
Summary
I can't figure out where System.Net.Http 4.1.1.0 is referenced, and I can't make ASP.NET Core update to use anything newer than 4.0.0.0. But if I paste my code and download the dependencies directly in the ASP.NET Core app, everything works fine.
Any ideas?
Update
It looks like the problem is the Microsoft.AspNetCore.Authentication Nuget package. Every time it is installed, it nukes the new version of System.Net.Http. Any ideas on how to prevent that?
Alright, I figured it out. It's the package Microsoft.AspNetCore.Authentication that is the problem.
After narrowing it down, it looks like Microsoft is aware of the problem: https://github.com/aspnet/Security/issues/1046. They'll be releasing a fix within a month, it sounds like.
Here is the commit that fixed it: https://github.com/aspnet/Security/commit/0f429324c54e380eeed235fea2bdfabb3639f43e

Is it possible to add a reference to NetCore library from a NetCore app without using the same solution?

I have a netstandard1.6 Project "MyLibrary"
I have a netcoreapp1.0 Project "MyApplication"
I have to reference "MyLibrary" from "MyApplication", without having those on the same solution.
Is it possible? How?
It's really confusing how DNX RC1 jumped into what Asp .Net 5 is right now, I can't seem to get going with it, I've read several articles and no documentation answered those questions to me.
With .Net Core, there are two ways to reference dependencies:
Reference another project in the "solution", where the solution is specified by a global.json file.
For example, the relevant part of your project.json could look like this:
"dependencies": {
"MyLibrary": { "target": "project" }
}
Reference a NuGet package from a known package source. Package source can be either web-based (like nuget.org), or it can be a directory. You can configure known package sources either locally or globally using a nuget.config file.
Example project.json excerpt:
"dependencies": {
"MyLibrary": "1.0.0"
}
For you, this means you have two options:
Add the library project to your "solution" by including it in your global.json.
Produce a NuGet package from your library (you can use dotnet pack for that), place it into a package source (probably just a directory) and configure that package source in a nuget.config file.

Make Class Library compatible to DNX Core 5

I'm trying to create my first ASP.NET 5 Web Api project. I need to add a previously create class library as a reference. So I go References -> Add reference and add the appropriate project. Unfortunately the reference is still unresolved.
Seems like it happens cause the reference goes to DNX 4.5.1 but not DNX Core 5.0. And in project.json it goes not to root dependencies but to frameworks:
"frameworks": {
"dnx451": {
"dependencies": {
"MyLibrary": "1.0.0-*"
}
},
"dnxcore50": { }
},
What should I do to my library to make it compatible to ASP.NET 5?
If the libraries that your project depends on don't support dotnetcore50 (CoreCLR) then you're out of luck. You need those to be ported first to CoreCLR before other CoreCLR libraries can use them.
Once you get a CoreCLR enabled dependency, you can add it to the top level dependencies node in project.json and then it will be available to all frameworks that your project supports.

Resources