dotnet restore aborts without error - centos

On CentOS, dotnet restore aborts without an error:
dotnet --verbose restore
Telemetry is: Enabled
log : Restoring packages for /home/forexsb/testapp/project.json...
Aborted
Here is my environment info:
dotnet --info
.NET Command Line Tools (1.0.0-preview2-1-003177)
Product Information:
Version: 1.0.0-preview2-1-003177
Commit SHA-1 hash: a2df9c2576
Runtime Environment:
OS Name: centos
OS Version: 7
OS Platform: Linux
RID: centos.7-x64
This is my project.json content:
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.AspNetCore.Server.Kestrel": "1.1.0"
},
"frameworks": {
"netcoreapp1.1": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.1.0"
}
}
}
}
}
Any ideas how to fix it?

Related

Using binary targets on Windows throws Unexpected end of JSON input

using prisma on Windows 10. I need to generate prisma in an offline mode. No internet access in pipeline. My package.json as below;
{
"name": "hello-prisma",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"description": "",
"devDependencies": {
"#types/node": "^17.0.13",
"prisma": "^3.8.1",
"ts-node": "^10.4.0",
"typescript": "^4.5.5"
}
}
and schema.prisma as follows;
generator client {
provider = "prisma-client-js"
engineType="binary"
binaryTargets=["native"]
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
.env file as follows;
DATABASE_URL=postgresql://postgres:postgres#localhost:5432/countrydb?schema=auth
PRISMA_CLI_QUERY_ENGINE_TYPE=binary
PRISMA_QUERY_ENGINE_BINARY=node_modules/#prisma/engines/query_engine-windows.dll
PRISMA_MIGRATION_ENGINE_BINARY=node_modules/#prisma/engines/migration-engine-windows.exe
PRISMA_INTROSPECTION_ENGINE_BINARY=node_modules/#prisma/engines/introspection-engine-windows.exe
PRISMA_FMT_BINARY=node_modules/#prisma/engines/prisma-fmt-windows.exe
DEBUG="*"
when I run npx prisma generate below JSON input error happens;
$ npx prisma generate
Environment variables loaded from .env
Prisma schema loaded from prisma\schema.prisma
Error: Get config: SyntaxError: Unexpected end of JSON input
Environment & setup
OS: Windows
Database: PostgreSQL
Node.js version: v14.17.2
Prisma Version
prisma : 3.8.1
#prisma/client : 3.8.1
Current platform : windows

Heroku can't find ExpressJS/Knex migrations

I have an Express.js api that works locally, using Postgresql via Knex/SQL queries.
I am trying to deploy to Heroku, however, when I attempt to migrate the DB I get the error that Heroku can't find the migration files.
Specifically, when I run the migration it throws:
Using environment: production Error: ENOENT: no such file or
directory, scandir '/app/migrations'
My migrations are located at my_app/db/migrations. The app folder mentioned in the error does not exist. Trying to figure out how to point to the correct folder.
Here is my package.json:
{
"name": "writerboard-express-api",
"version": "1.0.0",
"description": "",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"serve": "cross-env NODE_ENV=development nodemon server.js"
},
"keywords": [],
"author": "dariusgoore <dariusgoore#gmail.com> (dariusgoore.com)",
"license": "MIT",
"dependencies": {
"bcryptjs": "^2.4.3",
"body-parser": "^1.19.0",
"cors": "^2.8.5",
"dotenv": "^8.1.0",
"express": "^4.17.1",
"express-jwt": "^5.3.1",
"jsonwebtoken": "^8.5.1",
"knex": "^0.19.3",
"objection": "^1.6.9",
"objection-password": "^2.0.0",
"passport": "^0.4.0",
"passport-local": "^1.0.0",
"pg": "^7.12.1"
},
"devDependencies": {
"cross-env": "^5.2.1",
"nodemon": "^1.19.1"
}
}
My knexfile (myapp/knexfile.js):
const dotenv = require('dotenv');
dotenv.config({ path: "../.env" });
module.exports = {
development: {
client: 'postgresql',
connection: {
database: 'writerboard_dev', // update with env var
user: 'dariusgoore' // update with env var
},
pool: {
min: 2,
max: 10
},
migrations: {
tableName: 'knex_migrations',
directory: './db/migrations'
},
seeds: {
directory: './db/seeds'
}
},
production: {
client: 'postgresql',
connection: process.env.DATABASE_URL,
pool: {
min: 2,
max: 10
},
migrations: {
tableName: 'knex_migrations'
},
ssl: true
}
};
here is the server log from heroku:
2019-09-16T14:25:00.251226+00:00 heroku[web.1]: State changed from down to starting
2019-09-16T14:25:00.063523+00:00 app[api]: Release v8 created by user dariusgoore#gmail.com
2019-09-16T14:25:00.063523+00:00 app[api]: Deploy b697b243 by user dariusgoore#gmail.com
2019-09-16T14:25:00.000000+00:00 app[api]: Build succeeded
2019-09-16T14:25:03.700742+00:00 heroku[web.1]: Starting process with command `node server.js`
2019-09-16T14:25:08.369304+00:00 heroku[web.1]: State changed from starting to up
2019-09-16T14:25:07.885086+00:00 app[web.1]: Running on localhost:58146
FYI, the answer was in the knexfile.js. Needed to set the migrations directory for production.

How to resolve the dependency on Microsoft.EntityFrameworkCore.SqlServer and Microsoft.EntityFrameworkCore.Tools?

I am trying to create an application using Microsoft SQL Server database using Entity Framework Core.
This is what I have done so far
Step 1: From Nuget Package manager I have installed: Install-Package Microsoft.EntityFrameworkCore.SqlServer
Step 2: From Nuget Package manager I have installed (for Entity Framework commands) : Install-Package Microsoft.EntityFrameworkCore.Tools –Pre
And my project.json looks as under
{
"version": "1.0.0-*",
"buildOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.1",
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview3-final",
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
}
},
"frameworks": {
"netcoreapp1.0": {
"imports": "dnxcore50"
}
}
}
But it throws error
a) The dependency Microsoft.EntityFrameworkCore.SqlServer >= 1.0.1 could not be resolved.
b) The dependency Microsoft.EntityFrameworkCore.Tools >= 1.0.0-preview3-final could not be resolved.
Screen shot
I am using
VS 2015 Update 3
Not net framework 4.6.1
Why it is throwing the error and how can i fix it?
I think is because you are missing Microsoft.EntityFrameworkCore, try this:
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0",
"type": "platform"
},
"Microsoft.EntityFrameworkCore": "1.0.1",
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.1",
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview3-final"
}
You won't need to restore the packages using Nuget, the changes in project.json should automatically restore those packages.
The above works for me, if it doesn't for you maybe there's something else, let me know.

Using NuGet v3 api with AppVeyor

After we upgraded our web application to asp.net core 1.0 we're unable to get a successfull build within Appveyor.
There are several nuget packages issues, the first error is:
Microsoft.AspNetCore.Mvc 1.0.0 is not compatible with .NETCoreApp,Version=v1.0.
On of the feed that is used is https://www.nuget.org/api/v2 and we think it should use the V3 version to be able to build core 1.0 web projects.
Is our assumption correct and how do we force appveyor to use the v3 api instead v2?
How do we get a successful build for our asp.net core 1.0 project?
UPDATE
Our assumption seems not to be correct, with the command
nuget sources update -Name nuget.org -Source https://api.nuget.org/v3/index.json
the new v3 feed is successfully used but the build still fails with the same errors.
dotnet information from build-server:
.NET Command Line Tools (1.0.0-preview2-003121)
Product Information:
Version: 1.0.0-preview2-003121
Commit SHA-1 hash: removed
Runtime Environment:
OS Name: Windows
OS Version: 6.3.9600
OS Platform: Windows
RID: win81-x64
And our project.json:
{
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0",
"type": "default"
},
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.0",
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Logging": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0"
},
"tools": {
"Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
"Microsoft.DotNet.Watcher.Tools": "1.0.0-preview2-final",
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
},
"frameworks": {
"netcoreapp1.0": {}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true,
"compile": {
"exclude": [
"wwwroot",
"node_modules"
]
}
},
"runtimes": {
"win10-x64": {}
},
"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
},
//"publishExclude": [
// "**.user",
// "**.vspscc"
//],
"publishOptions": {
"include": [
"wwwroot",
"Views",
"Areas/**/Views",
"appsettings.json",
"web.config"
]
},
"scripts": {
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}
And global.json
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-preview2-003121"
}
}
Try updating nuget source during the build with this command:
nuget sources update -Name nuget.org -Source https://api.nuget.org/v3/index.json

How to update a product database by entity framework core 1.0 rc2

In entity framework core 1.0 RC1 when I published a website, it generated a ef.cmd file, I can ran ef database update to update the product database. How can I do it in RC2 when there is no ef.cmd file.
With RC2, you need to install the tooling via your project.json file, then issue dotnet restore. Here is a sample project.json which also brings in EntityFrameworkCore.SQLite:
{
"version": "1.0.0-*",
"buildOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0-rc2-3002702"
},
"Microsoft.EntityFrameworkCore.Tools": {
"type": "build",
"version": "1.0.0-preview1-final"
},
"Microsoft.EntityFrameworkCore.SQLite": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-final",
},
"tools": {
"Microsoft.EntityFrameworkCore.Tools": {
"imports": ["portable-net451+win8"],
"version": "1.0.0-preview1-final"
}
},
"frameworks": {
"netcoreapp1.0": {
"imports": "portable-net451+win8"
}
}
}
The important parts here are:
"Microsoft.EntityFrameworkCore.Tools": {
"type": "build",
"version": "1.0.0-preview1-final"
}
And
"tools": {
"Microsoft.EntityFrameworkCore.Tools": {
"imports": ["portable-net451+win8"],
"version": "1.0.0-preview1-final"
}
},
These tell the dotnet restore command to download the tooling for entity framework. Now you'll be able to use the .NET Core CLI Entity Framework functionality.
This will let you do things like:
$ dotnet ef migrations add myMigration
$ dotnet ef database update