I have a ASP.NET 5 website with 3 subprojects. The subprojects have a reference to EF 6.1. Locally everything works fine, but when I try to deploy the website to azure using the assistant, I get the error message
Dependency EntityFramework >= 6.1.3 could not be resolved in
XXX\wrap\PDWeb.Application\project.json 22
The generated project.json of the PDWeb.Application subproject is
{
"version": "1.0.0-*",
"frameworks": {
"net452": {
"wrappedProject": "../../Application/PDWeb.Application/PDWeb.Application.csproj",
"bin": {
"assembly": "../../Application/PDWeb.Application/obj/{configuration}/PDWeb.Application.dll",
"pdb": "../../Application/PDWeb.Application/obj/{configuration}/PDWeb.Application.pdb"
},
"dependencies": {
"PDWeb.Model": "1.0.0-*"
}
},
"net45": {
"wrappedProject": "../../src/Application/PDWeb.Application/PDWeb.Application.csproj",
"bin": {
"assembly": "../../src/Application/PDWeb.Application/obj/{configuration}/PDWeb.Application.dll",
"pdb": "../../src/Application/PDWeb.Application/obj/{configuration}/PDWeb.Application.pdb"
},
"dependencies": {
"PDWeb.Model": "1.0.0-*",
"EntityFramework": "6.1.3",
"PDWeb.Services": "1.0.0-*"
}
}
}
}
The complete build output can be found here
I solved the problem by converting my subprojects to *.xproj...
I had exactly the same issue, when I tried to publish my dnx project.
I run "dnu restore" in every subfolder into the wrap folder and the problem was solved.
In your solution folder is a wrap folder. In this folder are subfolders with project.json files. Open command prompt, go to every subfolder and execute "dnu restore"
Related
I'm currently working on a Xamarin.Forms project named ABCD, using macOS Sierra v10.12.6 and Visual Studio (VS) for Mac v7.3.2 (the steps leading up to this problem are detailed here).
Having updated my NETStandard.Library package from version 1.6.0 to 2.0.1*, I notice that the project.json file still says:
"frameworks": {
"netstandard1.5": {}
}
*VS update this package to 2.0.1, despite Terminal showing that dotnet --version is 2.1.3.
I went ahead and replaced netstandard1.5 with netstandard2.0 and rebuilt the project. But was then immediately met with this error:
Error: Your project is not referencing the ".NETPlatform,Version=v5.0" framework. Add a reference to ".NETPlatform,Version=v5.0" in the "frameworks" section of your project.json, and then re-run NuGet restore. (ABCD)
I've tried to fix this in the following ways:
1 – Updating project.json:
"frameworks": {
"netstandard2.0": {},
".NETPlatform,Version=v5.0": {}
}
2 (source) – Updating project.json:
"frameworks": {
"netstandard2.0": {},
".NETPlatform,Version=v5.0": {
"imports": ["netstandard2.0"]
}
3 (source) – Updating project.json:
"frameworks": {
"netstandard2.0": {},
".NETPlatform,Version=v5.0": {
"imports": [".NETCore,Version=v5.0"]
}
4 (source) – Updating project.json:
"frameworks": {
"netstandard2.0": {
"imports": [".NETCore,Version=v5.0"]
}
5 (source) – Updating project.json:
"frameworks": {
".NETPlatform,Version=v5.0": {
"imports": ["netstandard2.0"]
}
6 (source, source) – Updating ABCD.csproj:
<PropertyGroup>
<NuGetTargetMoniker> .NETStandard,Version=v2.0 </NuGetTargetMoniker>
</PropertyGroup>
I thought I might find something helpful here and here but wasn't successful.
The same error from above still remains after having tried the above fixes. How do I fix this?
EDIT:
7 (source) – Updating project.json:
"frameworks": {
"netstandard2.0": {},
"netplatform50": {}
}
Still seeing the same error.
This post suggests not using project.json but instead to do a dotnet migrate in your project root folder to convert it so that it uses .csproj instead
During dotnet build, it seems that generated files created during the precompile tasks are not used and the build failed.
precompile cannot be used for files generation? The documention is pretty light about it.
or do I have to deal with a delay to be sure that files are correctly writed on disk ?
Project.json:
{
"name": "Service",
"version": "0.0.1",
"dependencies": {
...
},
"frameworks": {
"netcoreapp1.0": {
"imports": "dnxcore50"
}
},
"scripts": {
"precompile": "%project:Directory%/protogen.bat"
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
}
}
Thanks
I assume you don't have this problem anymore, but to save time for anyone running into this issue, here is what is going on:
The problem is a bug in the dotnet tool where source files generated by a precompile command aren't included in the list of files to compile. See #1475 and #3807.
It was fixed by PR#4680. Upgrading to a newer version of .NET Core should fix it.
I wrote my open source library, LINQ to Twitter, with shared libraries to minimize deployment artifacts and handle platform specific features. I want to support .NET Core and am thinking that the fastest approach would be to reference the shared libraries. The Add References dialog didn't show the shared libraries, so I tried project.json:
{
"version": "1.0.0-*",
"dependencies": {
"NETStandard.Library": "1.6.0",
"LinqToTwitter.Shared": "*",
"LinqToTwitter.Shared.net": "*"
},
"frameworks": {
"netstandard1.6": {
"imports": "dnxcore50"
}
}
}
I tried a few combinations of versions, but didn't get anywhere. The error messages contain something like this:
The dependency LinqToTwitter.Shared >= * could not be resolved.
Next, I opened the *.xproj and pasted the following Imports into the Project section:
<Import Project="..\LinqToTwitter.Shared\LinqToTwitter.Shared.projitems"
Label="Shared" />
<Import
Project="..\LinqToTwitter.Shared.net\LinqToTwitter.Shared.net.projitems"
Label="Shared" />
This doesn't show references in VS, nothing in metadata, and (as it would follow) can't reference any shared library types from a console app that references the .NET core app.
if library is in the same solution you can reference it using target:project something like
{
"version": "1.0.0-*",
"dependencies": {
"NETStandard.Library": "1.6.0",
"LinqToTwitter.Shared": {"target": "project"},
"LinqToTwitter.Shared.net": {"target": "project"}
},
"frameworks": {
"netstandard1.6": {
"imports": "dnxcore50"
}
}
}
Good news - Visual Studio 2017 now allows .NET Core library projects to reference Shared projects.
I have created a ASP.net vnext class library project in Visual Studio 2015. Now I want to test my project. So, I want to use mocking stuffs in my test project.
Here is my project.json file
{
"version": "1.0.0-*",
"dependencies": {
"xunit": "2.0.0-rc3-build2880",
"xunit.runner.aspnet": "2.0.0-rc3-build52",
"My project name with version",
"Moq": "4.2.1502.911"
},
"commands": { "test": "xunit.runner.aspnet" },
"frameworks": {
"aspnet50": {
"dependencies": {
}
}
}
}
But I am getting error :Dependency Moq with the Version 4.2.1502.911 could not be resolved.
I also tried different version of Moq, but results the same: dependency error.
Without Mock I can't move further in testing.
Any help?
based on comment, the error is incorrect package manager settings :
the correct feeds to use are : nuget.org/api/v2 and myget.org/F/aspnetrelease for the asp ones
I am using VS2015 CTP5 and I am referencing a legacy class library compiled with 4.5.1. During compile, I get this warning:
The primary reference "D:\components.dll" could not be resolved because it was built against the ".NETFramework,Version=v4.5.1" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.5".
Here is my project.json after adding the reference
"frameworks": {
"aspnet50": {
"dependencies": {
"components": "1.0.0-*"
}
}
},
Since the "component" library is build for .net 45 and assuming that you build that library in an older version of visual studio, it will not work in aspnetcore5 but will work on aspnet5 (these are the new version for .net). if you want to get rid of the error and still use your component library, you will need remove the aspnetcore5 json node from the project.json file but the project that you building will not be compatible with aspnetcore5. So your project.json file for the frameworks section should look like this.
"frameworks": {
"aspnet50": {
"frameworkAssemblies": {
"System": "4.0.0.0"
},
"dependencies": {
}
},
"net45": {
"dependencies": { "components": "1.0.0"},
"frameworkAssemblies": { }
}
}
And your reference should look like, I have warning sing next to the component library because I don't have that in my code.
You can look at this question to get more information.
Question 1,
Question 2
Add the library to frameworkDependencies not dependencies
"net45": {
"frameworkAssemblies": {
"components": "1.0.0"
},
"dependencies": {
// NuGet packages go here
}
For me, none of the above worked and after spending a lot of hours investigating... I finally found a solution!
I have to create a new package in the NuGet Package Explorer for my dll, save and export it to a local folder (use the File->Save and File->Export commands). Then declare my local repository(folder) to Visual Studio, go to Tools->Options->NuGet Package Manager->Package Sources and insert a record for my local repository - see image below.