.net-core-2.0

How to get string array from core console appSettings.json file

风流意气都作罢 提交于 2020-05-15 08:47:25
问题 How do I return an string[] from the IConfigurationRoot object? File exists and is set to copy to output Code var builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("settings.json", optional: false, reloadOnChange: false); _configuration = builder.Build(); var arr = _configuration["stringArray"]; // this returns null var arr1 = _configuration["stringArray:0"]; // this works and returns first element Settings.json { "stringArray": [ "myString1",

System.Runtime, Version=4.2.1.0, PublicKeyToken=b03f5f7f11d50a3a has a higher version than referenced assembly

爱⌒轻易说出口 提交于 2020-05-13 04:26:50
问题 I upgraded my ASP.NET CORE application from sdk .NET Core 2.0 to .NET Core 2.1. I can run the solution in my localhost but when I deploy it to another server there is an exception. And the exception is below. The steps I have done to solve the issue so far are below and it throws the same error with all the modification that I did seems nothing works. Does anybody have any suggestion how to solve this issue? Steps I've done: Modify the setting for the project <PropertyGroup> <TargetFramework

System.Runtime, Version=4.2.1.0, PublicKeyToken=b03f5f7f11d50a3a has a higher version than referenced assembly

﹥>﹥吖頭↗ 提交于 2020-05-13 04:26:40
问题 I upgraded my ASP.NET CORE application from sdk .NET Core 2.0 to .NET Core 2.1. I can run the solution in my localhost but when I deploy it to another server there is an exception. And the exception is below. The steps I have done to solve the issue so far are below and it throws the same error with all the modification that I did seems nothing works. Does anybody have any suggestion how to solve this issue? Steps I've done: Modify the setting for the project <PropertyGroup> <TargetFramework

System.Runtime, Version=4.2.1.0, PublicKeyToken=b03f5f7f11d50a3a has a higher version than referenced assembly

风流意气都作罢 提交于 2020-05-13 04:25:48
问题 I upgraded my ASP.NET CORE application from sdk .NET Core 2.0 to .NET Core 2.1. I can run the solution in my localhost but when I deploy it to another server there is an exception. And the exception is below. The steps I have done to solve the issue so far are below and it throws the same error with all the modification that I did seems nothing works. Does anybody have any suggestion how to solve this issue? Steps I've done: Modify the setting for the project <PropertyGroup> <TargetFramework

How to get code coverage report in donetcore 2 application

安稳与你 提交于 2020-02-06 11:11:13
问题 I am new to dotnet core 2.0, not sure how to extract code coverage report with dotnet test command. Looking for help from the community. 回答1: OpenCover is an open source code coverage tool for dotnet core. You can use it in conjunction with ReportGenerator to get coverage reports. https://github.com/OpenCover/opencover https://github.com/danielpalme/ReportGenerator 回答2: Here is my .bat file to generate dotnet core. This will "pop" an index.htm file. This is just a .bat file version of what I

AutoMapper : Map both ways in Net Core 2 syntax

末鹿安然 提交于 2020-02-02 15:51:07
问题 What is syntax to map both ways in AutoMapper Net Core2? I need to map ProductViewModel and ProductDto both ways. This is not working, Startup.cs var config = new MapperConfiguration ( cfg => cfg.CreateMap<Models.ProductDto, Models.ProductViewModel>(), cfg => cfg.CreateMap<Models.ProductViewModel, Models.ProductDto>() ); var mapper = config.CreateMapper(); 回答1: I'd rather create a separate initializer and mapper. e.g here is my AutoMapperStartupTask class. public static class

Fix For “Package xxx is not compatible with netcoreapp2.0 (.NETCoreApp,Version=v2.0)”

怎甘沉沦 提交于 2020-01-14 12:47:46
问题 I created a blank solution with framework 4.6.1 and add a project core 2.0. This error show in output for many package 'Package xxx is not compatible with netcoreapp2.0 (.NETCoreApp,Version=v2.0)'. How Can I Fix it? 回答1: Couple of things you could try to make it work, provided the packages that you are trying to install really do support .NET CORE 2.0 . Make sure your VS is using NuGet 4.3 or greater. Within Visual Studio, go to Help -> About Visual Studio -> Notice the Nuget version and

Project 'ClassLibrary1.csproj' targets 'netcoreapp2.1'. It cannot be referenced by a project that targets '.NETFramework,Version=v4.7.2'

◇◆丶佛笑我妖孽 提交于 2020-01-13 07:52:26
问题 I have two class library project with the following setting: ClassLibrary1 --> Target framework-->.NET Core 2.1 ClassLibrary2 --> Target framework-->.NET Framework 4.7.2 Now I referenced the ClassLibrary1 project in ClassLibrary2 project. It was done successfully. But on rebuilding the project I am getting an error: Severity Code Description Project File Line Suppression State Error Project '..\ClassLibrary1\ClassLibrary1.csproj' targets 'netcoreapp2.1'. It cannot be referenced by a project

Delete character at nth position for each line in a text file

跟風遠走 提交于 2020-01-06 04:45:16
问题 I have multiple text files in folder. I need to delete character at the 8th character of each line in the text files. Text files have 100+ multiple rows How would I conduct this? Original file example: 123456789012345.... abcdefghijklmno.... New file: 12345679012345 abcdefgijklmno Reading this article is helpful: Add a character on each line of a string Note: Length of text lines can be variable (not sure if it matters- one row can have 20 characters, next line may have 30 characters, etc.

VS 2017 and Docker: Operation aborted

天涯浪子 提交于 2020-01-03 07:25:18
问题 .Net Core 2 came out, so I updated Visual Studio 2017 (Community) to release 15.3.0 (and subsequently 15.3.2) which has support for Docker which I've installed on my machine (Windows 10), and I believe I've configured things correctly. I created a basic Web API project—on .NET Core 2.0 without Docker—and that works. Now I add Docker support and I can't get it to run! I get the following error: How do I debug this? The only other Q&A I found wasn't helpful. If you recognize the error, do you