Im trying to follow a Entity Framework Core video in a .NET Core 2.1 DAL class library. In the DbContext.OnCofiguring the following code is placed :
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
base.OnConfiguring(optionsBuilder);
optionsBuilder.UseSqlServer("Server*.");
}
The problem is that the UseSQLServer is missing? From this its suggested to add Microsoft.EntityFrameworkCore.SqlServer nuget. When doing this I get some version conflicts that I dont know how to solve :
Severity Code Description Project File Line Suppression State
Error CS1061 'DbContextOptionsBuilder' does not contain a definition
for 'UseSqlServer' and no accessible extension method 'UseSqlServer'
accepting a first argument of type 'DbContextOptionsBuilder' could be
found (are you missing a using directive or an assembly
reference?) DataAccessLayer
--
Severity Code Description Project File Line Suppression State
Error Package restore failed. Rolling back package changes for
'DataAccessLayer'.
--
Severity Code Description Project File Line Suppression State
Error NU1605 Detected package downgrade:
Microsoft.Extensions.Configuration from 2.2.0 to 2.1.1. Reference the
package directly from the project to select a different version.
DataAccessLayer -> Microsoft.EntityFrameworkCore.SqlServer 2.2.3 ->
Microsoft.EntityFrameworkCore.Relational 2.2.3 ->
Microsoft.EntityFrameworkCore 2.2.3 -> Microsoft.Extensions.Logging
2.2.0 -> Microsoft.Extensions.Configuration.Binder 2.2.0 -> Microsoft.Extensions.Configuration (>= 2.2.0) DataAccessLayer ->
Microsoft.Extensions.Configuration (>= 2.1.1) DataAccessLayer
--
Severity Code Description Project File Line Suppression State
Error NU1605 Detected package downgrade:
Microsoft.Extensions.DependencyInjection from 2.2.0 to 2.1.1.
Reference the package directly from the project to select a different
version. DataAccessLayer -> Microsoft.EntityFrameworkCore.SqlServer
2.2.3 -> Microsoft.EntityFrameworkCore.Relational 2.2.3 -> Microsoft.EntityFrameworkCore 2.2.3 ->
Microsoft.Extensions.DependencyInjection (>= 2.2.0) DataAccessLayer
-> Microsoft.Extensions.DependencyInjection (>= 2.1.1) DataAccessLayer
--
I suspect that the project is using a couple of nuget packages and some of them is referencing a diffrent version of another nuget or dll.
It suggest to reference a package direcly? Does this mean that I should reference a dll manually? Where do I get the dll from?
The default severity for NU1605 is warning and since you're seeing it as an error, it means that your project has opt-in'ed into treating errors as warnings.
The reason for the package downgrade is probably due to NuGet's nearest-wins rule. The only way to avoid a downgrade is to add a PackageReference to the downgraded package to your project, that way the version you select is always nearest and transient dependencies can never downgrade it.
Otherwise you stop shooting yourself in the foot by either turning off "treat all warnings as errors" and list only the specific warnings you want treated as errors. Or, add NU1605 to the list of warnings to suppress (<NoWarn> in the csproj).
Related
I am still getting a reference error in vscode:
The type or namespace name 'Configuration' does not exist in the namespace 'Microsoft.Extensions'
You must install Microsoft.Extensions.Configuration with .Net CLI in Vscode .
You can use below code :
dotnet add package Microsoft.Extensions.Configuration --version 6.0.1
NOTE : In version you must use your current .NetFramework version
Nuget : Microsoft.Extensions.Configuration
The following steps solved this for me:
Deleted bin directory
Add packages
dotnet restore -f
I've switched my Visual Studio extension from old csproj format to the new SDK-style format and hoped to get everything I need with the following package references (previously I had to reference like 100 different packages in my packages.config)
<PackageReference Include="Microsoft.VisualStudio.LanguageServices" Version="3.8.0" />
<PackageReference Include="Microsoft.VisualStudio.SDK" Version="16.0.206" />
<PackageReference Include="NuGet.VisualStudio" Version="5.8.0" />
However, while the extension builds within Visual Studio, I run into problems when building the extension with MSBuild (when restoring NuGet packages):
"C:\Path\MyExt\MyExtension.sln" (Build target) (1) ->
"C:\Path\MyExt\MyExt.Tests\MyExt.Tests.csproj" (default target) (9) ->
C:\Path\MyExt\MyExt.Tests\MyExt.Tests.csproj : error NU1603: Microsoft.CodeAnalysis.EditorFeatures.Text 3.8.0 depends on Microsoft.VisualStudio.CoreUtility (>= 16.8.39) but Microsoft.VisualStudio.CoreUtility 16.8.39 was not found. An approximate best match of Microsoft.VisualStudio.CoreUtility 16.8.239 was resolved.
C:\Path\MyExt\MyExt.Tests\MyExt.Tests.csproj : error NU1603: Microsoft.CodeAnalysis.EditorFeatures.Text 3.8.0 depends on Microsoft.VisualStudio.CoreUtility (>= 16.8.39) but Microsoft.VisualStudio.CoreUtility 16.8.39 was not found. An approximate best match of Microsoft.VisualStudio.CoreUtility 16.8.239 was resolved.
C:\Path\MyExt\MyExt.Tests\MyExt.Tests.csproj : error NU1603: Microsoft.CodeAnalysis.EditorFeatures.Text 3.8.0 depends on Microsoft.VisualStudio.Text.Data (>= 16.8.39) but Microsoft.VisualStudio.Text.Data 16.8.39 was not found. An approximate best match of Microsoft.VisualStudio.Text.Data 16.8.239 was resolved.
C:\Path\MyExt\MyExt.Tests\MyExt.Tests.csproj : error NU1603: Microsoft.CodeAnalysis.EditorFeatures.Text 3.8.0 depends on Microsoft.VisualStudio.Text.Data (>= 16.8.39) but Microsoft.VisualStudio.Text.Data 16.8.39 was not found. An approximate best match of Microsoft.VisualStudio.Text.Data 16.8.239 was resolved.
C:\Path\MyExt\MyExt.Tests\MyExt.Tests.csproj : error NU1603: Microsoft.CodeAnalysis.EditorFeatures.Text 3.8.0 depends on Microsoft.VisualStudio.Text.Logic (>= 16.8.39) but Microsoft.VisualStudio.Text.Logic 16.8.39 was not found. An approximate best match of Microsoft.VisualStudio.Text.Logic 16.8.239 was resolved.
C:\Path\MyExt\MyExt.Tests\MyExt.Tests.csproj : error NU1603: Microsoft.CodeAnalysis.EditorFeatures.Text 3.8.0 depends on Microsoft.VisualStudio.Text.Logic (>= 16.8.39) but Microsoft.VisualStudio.Text.Logic 16.8.39 was not found. An approximate best match of Microsoft.VisualStudio.Text.Logic 16.8.239 was resolved.
Indeed, the packages are not on NuGet. Is this a problem with the Microsoft.VisualStudio.SDK package? Am I doing something wrong?
I think the issue is related the Microsoft.CodeAnalysis.EditorFeatures package itself. And you should contact with the author.
It's just that the problem is magnified by the new-sdk project and the true you set.
Actually, I faced the same issue in my side with even net core console project.
You can see this:
The nuget package has dependencies are >=16.8.39.
However, Microsoft.VisualStudio.CoreUtility does not have version 16.8.39 version but has 16.8.239. This is designed by the author. And according to the mechanism of nuget, it will install the minimum version of dependencies, but the new-sdk style project cannot automatically identify the invalid version, and this warning appears. But non-sdk style projects with packages.config will automatically install the valid version of the nuget dependencies.
So this issue is the dual influence of the design issue of the nuget package and the particularity of the new-sdk style project. It's just magnified in this case.
============================================
Workaround
To solve the issue, try these:
1) First, disable TreatWarningsAsErrors node under Project Properties-->Build
2) manually install
Microsoft.VisualStudio.CoreUtility 16.8.239
Microsoft.VisualStudio.Text.Data 16.8.239
Microsoft.VisualStudio.Text.Logic 16.8.239
nuget packages additionally to update the dependencies.
3) then enable TreatWarningsAsErrors to check.
I try to setup a continuous integration build on VisualStudio.com to build my project. Since I upgraded to .net 4.6.2 and working with the System.ValueType, the build fails:
MinimalMonitoringClient\MMCThinNetwork\Connection.cs(91,23): Error
CS1519: Invalid token '(' in class, struct, or interface member
declaration Connection.cs(91,23): error CS1519: Invalid token '(' in
class, struct, or interface member declaration
[d:\a\1\s\MinimalMonitoringClient\MMCThinNetwork\MMCThinNetwork.csproj]
MinimalMonitoringClient\MMCThinNetwork\Connection.cs(91,47): Error
CS1044: Cannot use more than one type in a for, using, fixed, or
declaration statement Connection.cs(91,47): error CS1044: Cannot use
more than one type in a for, using, fixed, or declaration statement
[d:\a\1\s\MinimalMonitoringClient\MMCThinNetwork\MMCThinNetwork.csproj]
MinimalMonitoringClient\MMCThinNetwork\Connection.cs(91,64): Error
CS1002: ; expected
It compiles on my local computer
The NuGet Package "System.ValueType" is installed
No Package Folder on TFS
The Task "Restore NuGet Packages" is included in the build process
NuGet Restore Build Step finishes successfully
2017-04-22T14:42:13.2402898Z ##[section]Starting: NuGet restore
**/*.sln 2017-04-22T14:42:13.2512895Z ============================================================================== 2017-04-22T14:42:13.2512895Z Task : NuGet Installer
2017-04-22T14:42:13.2512895Z Description : Installs or restores
missing NuGet packages 2017-04-22T14:42:13.2512895Z Version :
0.2.31 2017-04-22T14:42:13.2512895Z Author : Microsoft Corporation 2017-04-22T14:42:13.2512895Z Help : More
Information
2017-04-22T14:42:13.2512895Z
============================================================================== 2017-04-22T14:42:14.3517087Z [command]C:\Windows\system32\chcp.com
65001 2017-04-22T14:42:14.3517087Z Active code page: 65001
2017-04-22T14:42:14.4246880Z Detected NuGet version 3.3.0.212 / 3.3.0
2017-04-22T14:42:14.4276880Z SYSTEMVSSCONNECTION exists true
2017-04-22T14:42:14.4286876Z To connect to NuGet feeds hosted in your
Team Services account/TFS project collection on this build agent, edit
your build definition to choose a higher version of nuget or specify a
path to a NuGet.config containing the package sources you wish to use.
2017-04-22T14:42:14.4316868Z
[command]d:\a_tasks\NuGetInstaller_333b11bd-d341-40d9-afcf-b32d5ce6f23b\0.2.31\node_modules\nuget-task-common\NuGet\3.3.0\NuGet.exe
restore -NonInteractive
d:\a\1\s\MinimalMonitoringClient\MinimalMonitoringClient.sln
2017-04-22T14:42:15.2210188Z MSBuild auto-detection: using msbuild
version '14.0' from 'C:\Program Files (x86)\MSBuild\14.0\bin'.
2017-04-22T14:42:15.4566895Z Feeds used: 2017-04-22T14:42:15.4566895Z
C:\Users\buildguest\AppData\Local\NuGet\Cache
2017-04-22T14:42:15.4576898Z https://api.nuget.org/v3/index.json
2017-04-22T14:42:15.4576898Z 2017-04-22T14:42:15.4786896Z Restoring
NuGet package System.ValueTuple.4.3.0. 2017-04-22T14:42:15.4896877Z
Restoring NuGet package Newtonsoft.Json.10.0.2.
2017-04-22T14:42:16.5110192Z Adding package 'System.ValueTuple.4.3.0'
to folder 'd:\a\1\s\MinimalMonitoringClient\packages'
2017-04-22T14:42:16.5330192Z Added package 'System.ValueTuple.4.3.0'
to folder 'd:\a\1\s\MinimalMonitoringClient\packages'
2017-04-22T14:42:16.7550436Z Adding package 'Newtonsoft.Json.10.0.2'
to folder 'd:\a\1\s\MinimalMonitoringClient\packages'
2017-04-22T14:42:16.7780484Z Added package 'Newtonsoft.Json.10.0.2' to
folder 'd:\a\1\s\MinimalMonitoringClient\packages'
2017-04-22T14:42:16.8080211Z ##[section]Finishing: NuGet restore
**/*.sln
In Build Solution the VS Version is set to: 2017
Clean: True
Restore NuGet Packages: True
Thanks in advance
You need to use the Hosted VS2017 Build Agent to compile things using VS2017.
I'm using Xamarin Forms with Visual Studio 2015. I get this error while I'm trying to add a messaging plugin.
Severity Code Description Project File Line Suppression State
Error Unable to resolve dependencies. 'Xamarin.Android.Support.v4 23.0.1.3' is not compatible with 'Xamarin.Android.Support.Design 23.0.1.3 constraint: Xamarin.Android.Support.v4 (>= 23.0.1.3)', 'Xamarin.Forms 2.2.0.45 constraint: Xamarin.Android.Support.v4 (= 23.3.0)'. 0
I have already updated Visual Studio and Xamarin, but still get this error.
What else should I do to fix this error?
This is a dependency issue. For Xamarin.Forms 2.2.0.45, the dependencies are
Xamarin.Android.Support.v4 (= 23.3.0)
Xamarin.Android.Support.Design (= 23.3.0)
Xamarin.Android.Support.v7.AppCompat (= 23.3.0)
Xamarin.Android.Support.v7.CardView (= 23.3.0)
Xamarin.Android.Support.v7.MediaRouter (= 23.3.0)
Note version conflict between the above and the error: 'Xamarin.Android.Support.v4 23.0.1.3' is not compatible with 'Xamarin.Android.Support.Design 23.0.1.3 constraint: Xamarin.Android.Support.v4 (>= 23.0.1.3)'
You will need to install the compatible version of the messaging plugin you’d like to use. Here is a related troubleshooting guide: https://developer.xamarin.com/guides/xamarin-forms/troubleshooting/.
I have a custom library with source code that successfully compiles and produces the .dll file.
Question: what's the best approach to include this dll in a HoloLens project considering the following errors?
My approach
The project.json file of the standalone library is the following:
{
"dependencies": {
"Microsoft.NETCore.UniversalWindowsPlatform": "5.1.0",
"Newtonsoft.Json": "9.0.1"
},
"frameworks": {
"uap10.0": {}
},
"runtimes": {
"win10-arm": {},
"win10-arm-aot": {},
"win10-x86": {},
"win10-x86-aot": {},
"win10-x64": {},
"win10-x64-aot": {}
}
}
Or I have also the opportunity to add it as a NuGet package depending on:
- Microsoft.NETCore.UniversalWindowsPlatform (>= 5.2.2)
- Newtonsoft.Json (>= 9.0.1)
- Microsoft.EntityFrameworkCore.Tools (>= 1.0.0-preview2-final)
- Microsoft.EntityFrameworkCore.Sqlite (>= 1.0.1)
Then I need to include this library in another VS2015 solution produced by Unity for Hololens. The solution automatically built by Unity consists of 3 projects: 1) Assembly-CSharp containing a HoloToolkit folder, 2) Assembly-CSharp firstpass and 3) Origami
I took a script from HoloToolkit for Unity folder and I applied it on a GameObject. When an event is triggered - and it happens successfully - I want to call some functions provided by this custom library to process it from the same script, say GazeManager.cs. The project.json of the project 1) is the following
{
"dependencies": {
"Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0"
},
"frameworks": {
"uap10.0": {}
},
"runtimes": {
"win10-arm": {},
"win10-arm-aot": {},
"win10-x86": {},
"win10-x86-aot": {},
"win10-x64": {},
"win10-x64-aot": {}
}
}
I tried in 2 ways:
In GazeManager.cs I added using MyLibrary in the code and add it as a reference in ReferenceManager. The library gets correctly recognized but then just declaring a variable like public MyLibrary objectInMyLibrary makes the switch from a program correctly compiling to a program with the following error:
The command ""C:\Users\Antonino\Documents\UnityToVS2015Projects\HoloAcademy101 - Origami\Origami\App\Unity\Tools\AssemblyConverter.exe" -platform=uap -lock="C:\Users\lakeb\Documents\UnityToVS2015Projects\HoloAcademy101 - Origami\Origami\App\Origami\project.lock.json" -bits=32 -configuration=Debug -removeDebuggableAttribute=False -path="." -path="..\Players\UAP\x86\Debug" "C:\Users\lakeb\Documents\UnityToVS2015Projects\HoloAcademy101 - Origami\Origami\App\Origami\Assembly-CSharp.dll" "C:\Users\lakeb\Documents\UnityToVS2015Projects\HoloAcademy101 - Origami\Origami\App\Origami\Assembly-CSharp-firstpass.dll" "C:\Users\lakeb\Documents\UnityToVS2015Projects\HoloAcademy101 - Origami\Origami\App\Origami\UnityEngine.dll" "C:\Users\lakeb\Documents\UnityToVS2015Projects\HoloAcademy101 - Origami\Origami\App\Origami\UnityEngine.UI.dll" "C:\Users\lakeb\Documents\UnityToVS2015Projects\HoloAcademy101 - Origami\Origami\App\Origami\UnityEngine.HoloLens.dll" "C:\Users\lakeb\Documents\UnityToVS2015Projects\HoloAcademy101 - Origami\Origami\App\Origami\UnityEngine.Networking.dll" "C:\Users\lakeb\Documents\UnityToVS2015Projects\HoloAcademy101 - Origami\Origami\App\Origami\UnityEngine.VR.dll"" exited with code 1.
[cancelling the previous steps to have a compiling Origami again] the second way I thought is adding it through the insertion of the line in the project.json file
"my.hololens.library": "version"
and in this case I got the following errors
Payload contains two or more files with the same destination path 'System.Net.Sockets.dll'. Source files: C:\Users\Antonino.nuget\packages\runtime.win.System.Net.Sockets\4.1.0\runtimes\win\lib\netcore50\System.Net.Sockets.dllC:\Users\Antonino.nuget\packages\System.Net.Sockets\4.0.0\lib\netcore50\System.Net.Sockets.dll
Payload contains two or more files with the same destination path 'System.Diagnostics.Tools.dll'. Source files: C:\Users\Antonino.nuget\packages\runtime.any.System.Diagnostics.Tools\4.0.1\lib\netcore50\System.Diagnostics.Tools.dllC:\Users\Antonino.nuget\packages\System.Diagnostics.Tools\4.0.0\lib\netcore50\System.Diagnostics.Tools.dll
Payload contains two or more files with the same destination path 'System.Threading.Timer.dll'. Source files: C:\Users\Antonino.nuget\packages\runtime.any.System.Threading.Timer\4.0.1\lib\netcore50\System.Threading.Timer.dllC:\Users\Antonino.nuget\packages\System.Threading.Timer\4.0.0\lib\netcore50\System.Threading.Timer.dll
Version conflict detected for System.Collections. Origami (>= 1.0.0) -> Assembly-CSharp (>= 1.0.0) -> my.hololens.library (>= version) -> Microsoft.EntityFrameworkCore.Tools (>= 1.0.0-preview2-final) -> Microsoft.EntityFrameworkCore.Design (>= 1.0.0-preview2-final) -> Microsoft.EntityFrameworkCore.Design.Core (>= 1.0.0-preview2-final) -> Microsoft.AspNetCore.Hosting.Abstractions (>= 1.0.0) -> Microsoft.AspNetCore.Http.Abstractions (>= 1.0.0) -> System.Reflection.TypeExtensions (>= 4.1.0) -> System.Linq (>= 4.1.0) -> System.Collections (>= 4.0.11) Origami (>= 1.0.0) -> Microsoft.NETCore.UniversalWindowsPlatform (>= 5.0.0) -> Microsoft.NETCore.Runtime (>= 1.0.0) -> Microsoft.NETCore.Runtime.CoreCLR-arm (>= 1.0.0) -> System.Collections (= 4.0.10).
One or more packages are incompatible with UAP,Version=v10.0 (win10-x86-aot).
One or more packages are incompatible with UAP,Version=v10.0 (win10-arm-aot).
System.Reflection.Emit.ILGeneration 4.0.1 provides a compile-time reference assembly for System.Reflection.Emit.ILGeneration on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-x86-aot.
System.Reflection.Emit.ILGeneration 4.0.1 provides a compile-time reference assembly for System.Reflection.Emit.ILGeneration on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-x64-aot.
System.Reflection.Emit.ILGeneration 4.0.1 provides a compile-time reference assembly for System.Reflection.Emit.ILGeneration on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-x86-aot.
System.Reflection.Emit.ILGeneration 4.0.1 provides a compile-time reference assembly for System.Reflection.Emit.ILGeneration on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-x64-aot.
One or more packages are incompatible with UAP,Version=v10.0 (win10-x64-aot).
Version conflict detected for System.Collections. Assembly-CSharp (>= 1.0.0) -> my.hololens.library (>= version) -> Microsoft.EntityFrameworkCore.Tools (>= 1.0.0-preview2-final) -> Microsoft.EntityFrameworkCore.Design (>= 1.0.0-preview2-final) -> Microsoft.EntityFrameworkCore.Design.Core (>= 1.0.0-preview2-final) -> Microsoft.AspNetCore.Hosting.Abstractions (>= 1.0.0) -> Microsoft.AspNetCore.Http.Abstractions (>= 1.0.0) -> System.Reflection.TypeExtensions (>= 4.1.0) -> System.Linq (>= 4.1.0) -> System.Collections (>= 4.0.11) Assembly-CSharp (>= 1.0.0) -> Microsoft.NETCore.UniversalWindowsPlatform (>= 5.0.0) -> Microsoft.NETCore.Runtime (>= 1.0.0) -> Microsoft.NETCore.Runtime.CoreCLR-arm (>= 1.0.0) -> System.Collections (= 4.0.10).
One or more packages are incompatible with UAP,Version=v10.0 (win10-x64-aot).
One or more packages are incompatible with UAP,Version=v10.0 (win10-x86-aot).
System.Reflection.Emit.ILGeneration 4.0.1 provides a compile-time reference assembly for System.Reflection.Emit.ILGeneration on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-arm-aot.
One or more packages are incompatible with UAP,Version=v10.0 (win10-arm-aot).
System.Reflection.Emit.ILGeneration 4.0.1 provides a compile-time reference assembly for System.Reflection.Emit.ILGeneration on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-arm-aot.
I'm puzzled on what to go on. Somebody said to produce a portable library, and I also tried to study here the relationship among NETFramework, NETCore and NETStandard but it seems more complex than expected.
Unity 3d does not support integration of libraries that use the .Net Core framework. Try creating your library as a .Net Framework 3.5 Library and drop it in the Assets/Plugins folder of your Unity project.
You need to create a UWP Library project and port your code to this project and compile , remove errors
Place compiled dll in assets folder
Update Inspector properties as shown below
Now you can access this dll in your unity scripts under #if !UNITY_EDITOR block