I'm converting an aspnet5/rc-1 website to the released aspnet core. I'm running into a problem involving user secrets in the development environment.
The call to AddUserSecrets, in the Startup constructor, throws an exception:
public Startup( IHostingEnvironment env )
{
// Set up configuration sources.
var builder = new ConfigurationBuilder()
.AddJsonFile( "appsettings.json" )
.AddJsonFile( $"appsettings.{env.EnvironmentName}.json", optional: true );
if( env.IsDevelopment() )
{
// this line blows up
builder.AddUserSecrets();
}
builder.AddEnvironmentVariables();
Configuration = builder.Build();
The error message is something to the effect that the project.json file could not be found in the bin/Debug/netcoreapp1.0 folder...which is weird, because I wouldn't expect to find the project.json file in the distributable executable folder in the first place.
This all worked fine under rc1, so something has changed.
Additional Info
Here is the exception detail:
System.InvalidOperationException was unhandled by user code
HResult=-2146233079 Message=Unable to locate a project.json at
'C:\Programming\SpeedView\src\SpeedView\bin\Debug\netcoreapp1.0\'.
Source=Microsoft.Extensions.Configuration.UserSecrets StackTrace:
at Microsoft.Extensions.Configuration.UserSecrets.PathHelper.GetSecretsPath(IFileProvider
provider)
at Microsoft.Extensions.Configuration.ConfigurationExtensions.AddUserSecrets(IConfigurationBuilder
configuration)
at SpeedView.Startup..ctor(IHostingEnvironment env) in C:\Programming\SpeedView\src\SpeedView\Startup.cs:line 48
InnerException:
Here is project.json file:
{
"userSecretsId": "aspnet5-SpeedView-f526a1b2-f58b-4e04-b189-8442609eff8c",
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0",
"type": "platform"
},
"Microsoft.AspNetCore.Antiforgery": "1.0.0",
"Microsoft.AspNetCore.Authentication.Cookies": "1.0.0",
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0",
"Microsoft.AspNetCore.Identity.EntityFrameworkCore": "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.EntityFrameworkCore.SqlServer": "1.0.0",
"Microsoft.EntityFrameworkCore.SqlServer.Design": {
"version": "1.0.0",
"type": "build"
},
"Microsoft.EntityFrameworkCore.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Configuration.UserSecrets": "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",
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"AutoMapper": "5.0.2",
"Serilog.Extensions.Logging": "1.1.0",
"Serilog.Sinks.ColoredConsole": "2.0.0",
"Serilog.Sinks.Literate": "2.0.0",
"Serilog.Sinks.RollingFile": "2.2.0",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final"
},
"tools": {
"BundlerMinifier.Core": "2.0.238",
"Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
"Microsoft.Extensions.SecretManager.Tools": "1.0.0-preview2-final",
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.0.0-preview2-final",
"imports": [
"portable-net45+win8"
]
}
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"portable-net45+win8"
]
}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"publishOptions": {
"include": [
"wwwroot",
"Views",
"Areas/**/Views",
"appsettings.json",
"web.config"
]
},
"scripts": {
"prepublish": [ "npm install", "bower install", "gulp siteprep" ]
}
}
Don't forget to set your BasePath:
public Startup( IHostingEnvironment env )
{
// Set up configuration sources.
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath) // Add this line <-----
.AddJsonFile( "appsettings.json" )
.AddJsonFile( $"appsettings.{env.EnvironmentName}.json", optional: true );
Related
I have build my electron app with help of https://medium.com/jspoint/packaging-and-distributing-electron-applications-using-electron-builder-311fc55178d9
it was was success (windows only). but after install published app, i am getting error as shown in screenshort
my scripts as below
package.json
"name": "aux-services",
"version": "1.0.0",
"description": "Mobile Repair Tracking System",
"main": "main.js",
"scripts": {
"start": "electron .",
"postinstall": "electron-builder install-app-deps",
"pack": "electron-builder -w"
},
"repository": {
"type": "git",
"url": "git+https://github.com/shafeequeot/Mobile-Service-Tracker.git"
},
"author": "AuxWall",
"email": "shafeequeot#gmail.com",
"url": "https://auxwall.com",
"license": "MIT",
"bugs": {
"url": "https://github.com/shafeequeot/Mobile-Service-Tracker/issues"
},
"homepage": "https://github.com/shafeequeot/Mobile-Service-Tracker#readme",
"devDependencies": {
"electron": "^11.1.1",
"electron-builder": "^22.14.13",
"sqlite3": "^5.0.2"
},
"dependencies": {
}
}
electron-builder.json
{
"appId": "com.auxWall.service",
"productName": "Aux Services",
"copyright": "AuxWall",
"directories": {
"app": ".",
"output": "out",
"buildResources": "build-res"
},
"files": [
"package.json",
"**/*",
"node_modules"
],
"dmg": {
"background": null,
"backgroundColor": "#ffffff",
"window": {
"width": "400",
"height": "300"
},
"contents": [
{
"x": 100,
"y": 100
},
{
"x": 300,
"y": 100,
"type": "link",
"path": "/Applications"
}
]
},
"mac": {
"target": "dmg",
"category": "public.auxWall.services"
},
"win": {
"target": "nsis"
},
"linux": {
"target": "AppImage",
"category": "Utility"
}
}
can anybody help me to resolve this issue?
If sqlite3 is required during normal operation of your Electron application and not just during development then you will need to added sqlite3 as a dependency.
IE: Move "sqlite3": "^5.0.2" from "devDependencies": { ... } to "dependencies": { ... }.
package.json
{
"name": "aux-services",
"version": "1.0.0",
"description": "Mobile Repair Tracking System",
"main": "main.js",
"scripts": {
"start": "electron .",
"postinstall": "electron-builder install-app-deps",
"pack": "electron-builder -w"
},
"repository": {
"type": "git",
"url": "git+https://github.com/shafeequeot/Mobile-Service-Tracker.git"
},
"author": "AuxWall",
"email": "shafeequeot#gmail.com",
"url": "https://auxwall.com",
"license": "MIT",
"bugs": {
"url": "https://github.com/shafeequeot/Mobile-Service-Tracker/issues"
},
"homepage": "https://github.com/shafeequeot/Mobile-Service-Tracker#readme",
"devDependencies": {
"electron": "^11.1.1",
"electron-builder": "^22.14.13"
},
"dependencies": {
"sqlite3": "^5.0.2"
}
}
I'm following steps here to work with the Azure DocumentDB emulator: https://learn.microsoft.com/en-us/azure/cosmos-db/local-emulator
I have the emulator up and running:
I have downloaded the sample .Net Core app. When I attempt to load it I get the following error:
I'm running:
My project file looks like this:
{
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.1",
"type": "platform"
},
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.1",
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.AspNetCore.Routing": "1.0.1",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
"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",
"Microsoft.Azure.DocumentDB.Core": "*"
},
"tools": {
"BundlerMinifier.Core": "2.0.238",
"Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"portable-net45+win8"
]
}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
},
"publishOptions": {
"include": [
"wwwroot",
"**/*.cshtml",
"appsettings.json",
"web.config"
]
},
"scripts": {
"prepublish": [ "bower install", "dotnet bundle" ],
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}
Anyone else have this problem or know how to fix it?
The quickstart sample is xproj project.json so after conversion to csproj/MSBuild it is necessary to modify the csproj file etc. as outlined here:
https://learn.microsoft.com/en-us/dotnet/core/migration/
I've created a simple web app with SignalR Core and deployed it into Azure, and enabled websockets for app service.
But after that when I try to access it using https:// it returns HTTP ERROR 500.
Any idea what is wrong? Do I need to set anything else in settings to make it work over https?
when I try to access it using https:// it returns HTTP ERROR 500.
Please make sure your SignalR app could run without any error before publishing it to Azure website. I have a sample app that works fine on local and Azure, please refer to it.
Project.json
{
"dependencies": {
"Gray.Microsoft.AspNetCore.SignalR.Server": "0.2.0-alpha1",
"Microsoft.AspNetCore.WebSockets": "1.0.1",
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.1",
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.AspNetCore.Routing": "1.0.1",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Logging": "1.1.1",
"Microsoft.Extensions.Logging.Console": "1.1.1",
"Microsoft.Extensions.Logging.Debug": "1.1.1",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
"Microsoft.NETCore.App": {
"version": "1.0.1",
"type": "platform"
},
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0",
"Microsoft.AspNet.SignalR.Client": "2.2.1"
},
"tools": {
"BundlerMinifier.Core": "2.0.238",
"Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"portable-net45+win8"
]
}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
},
"publishOptions": {
"include": [
"wwwroot",
"**/*.cshtml",
"appsettings.json",
"web.config"
]
},
"scripts": {
"prepublish": [ "bower install", "dotnet bundle" ],
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}
Startup class
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddMvc();
services.AddSignalR(options=> {
options.Hubs.EnableDetailedErrors = true;
});
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseBrowserLink();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseStaticFiles();
app.UseWebSockets();
app.UseSignalR();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
Website Chat page
Besides, this article is about “Getting started with SignalR Core”, please refer to it.
I am deploying a .NET core application from GitHub to an Azure App Service and receiving the following error:
Feeds used:
https://api.nuget.org/v3/index.json D:\Program Files (x86)\dotnet\dotnet.exe build "D:\home\site\repository\src\MY_APP"
--configuration Release --no-dependencies --build-base-path "D:\home\site\repository\src\artifacts" Microsoft (R) Build Engine
version 15.1.0.0 Copyright (C) Microsoft Corporation. All rights
reserved. MSBUILD : error MSB1001: Unknown switch.
[D:\home\site\repository\src\MY_APP\MY_APP.xproj] Switch:
--build-base-path
As far as a I can tell, build-base-path is a valid parameter.
This application was deploying fine. In fact, I even tried to redeploy the last good deployment and it too is failing now.
Here is the project.json:
{
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"runtimeOptions": {
"gcServer": true
},
"userSecretsId": "aspnet-rverbio-457D3F4C-1C63-4A4C-8D65-5EA4FA4EE5F9",
"dependencies": {
"Microsoft.ApplicationInsights.AspNetCore": "1.0.2",
"Microsoft.AspNetCore.Authentication.Cookies": "1.1.0",
"Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.1.0",
"Microsoft.AspNetCore.Diagnostics": "1.1.0",
"Microsoft.AspNetCore.Mvc": "1.1.0",
"Microsoft.AspNetCore.Mvc.TagHelpers": "1.1.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
"Microsoft.AspNetCore.StaticFiles": "1.1.0",
"Microsoft.Azure.DocumentDB.Core": "0.1.0-preview",
"Microsoft.Extensions.Configuration.Abstractions": "1.1.0",
"Microsoft.Extensions.Configuration.FileExtensions": "1.1.0",
"Microsoft.Extensions.Configuration.Json": "1.1.0",
"Microsoft.Extensions.Configuration.UserSecrets": "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",
//"Microsoft.IdentityModel.Clients.ActiveDirectory": "3.13.7",
"Microsoft.IdentityModel.Protocol.Extensions": "2.0.0-beta6-207211625",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.1.0",
"System.IdentityModel.Tokens.Jwt": "5.1.0"
},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.1"
}
},
"imports": "dnxcore50"
}
},
"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": {
"version": "1.1.0-preview4-final"
},
"Microsoft.Extensions.SecretManager.Tools": {
"version": "1.1.0-preview4-final"
}
},
"publishOptions": {
"include": [
"wwwroot",
"Views",
"appsettings.json",
"config.json",
"web.config"
]
},
"scripts": {
"precompile": [
"powershell -f Download-Secrets.ps1"
],
"prepublish": [
"npm install",
"npm run build"
],
"postpublish": [
"dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%"
]
}
}
Any help would be appreciated.
Update
A colleague of mine created a global.json with the following contents and deployments are working!
{
"sdk": {
"version": "1.0.0-preview2-003131"
}
}
I try to use Windows Azure Storage inside my dotnet core system (my first dotnet core project). I tried the unit test for Azure Storage with dotnet core and it builds well.
But when I try to include the dependency to Azure Storage in my project.json, I receive this message:
Unable to resolve 'Microsoft.WindowsAzure.Storage (>= 7.2.0)' for '.NETCoreApp,Version=v1.0'.
Here is my full project.json file
{
"dependencies": {
"Microsoft.AspNetCore.Mvc": "1.0.*",
"Microsoft.AspNetCore.Mvc.TagHelpers": "1.0.*",
"Microsoft.AspNetCore.Server.IISIntegration":"1.0.*",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.*",
"Microsoft.AspNetCore.Diagnostics": "1.0.*",
"Microsoft.Extensions.Configuration.EnvironmentVariables":"1.0.*",
"Microsoft.Extensions.Configuration.FileExtensions": "1.0.*",
"Microsoft.Extensions.Configuration.Json": "1.0.*",
"Microsoft.Extensions.Configuration.CommandLine": "1.0.0",
"Microsoft.Extensions.Configuration.UserSecrets": "1.0.0",
"Microsoft.Extensions.Logging":"1.0.*",
"Microsoft.Extensions.Logging.Console": "1.0.*",
"Microsoft.Extensions.Logging.Debug": "1.0.*",
"Microsoft.EntityFrameworkCore": "1.0.*",
"Microsoft.EntityFrameworkCore.Sqlite": "1.0.*",
"Microsoft.EntityFrameworkCore.Design": { "version": "1.0.0-preview2-final", "type": "build" },
"Autofac": "4.0.0-rc3-309",
"Autofac.Extensions.DependencyInjection": "4.0.0-rc3-309",
"FluentValidation": "6.4.0-beta3",
// "Serilog" : "2.0.0",
// "Serilog.Extensions.Logging" : "1.0.0",
// "Serilog.Sinks.Console" : "2.0.0"
"Microsoft.AspNetCore.Authentication.Cookies": "1.0.0",
"Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0",
"Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0",
"Microsoft.AspNetCore.Razor.Tools": { "version": "1.0.0-preview2-final", "type": "build" },
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0",
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.WindowsAzure.Storage": "7.2.0.0-*"
},
"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": {
"version": "1.0.0-preview2-final",
"imports": "portable-net45+win8+dnxcore50"
},
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
"Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
"BundlerMinifier.Core": "2.0.238",
"Microsoft.Extensions.SecretManager.Tools": "1.0.0-preview2-final",
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.0.0-preview2-final",
"imports": [
"portable-net45+win8"
]
}
},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0",
"type": "platform"
}
},
"imports": [
// "dotnet5.6",
"dnxcore50",
"portable-net45+win8"
]
}
},
"buildOptions": {
"define": [ "NETCORE"],
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"runtimeOptions": {
"gcServer": true
},
"publishOptions": {
"include": [
"wwwroot",
"Views",
"Areas/**/Views",
"appsettings.json",
"web.config"
]
},
"scripts": {
"precompile": [ "dotnet bundle" ],
"prepublish": [ "bower install" ],
"postpublish": [
"dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%"
]
},
"tooling": {
"defaultNamespace": "Wod6000"
}
}
Do you have an idea on what is wrong?
Our package is named WindowsAzure.Storage. Can you try that instead?