I'm trying to debug a NETCore project in VS Code but launching the debugger gives me the following error:
MSBUILD : error MSB4025: The project file could not be loaded.
Data at the root level is invalid. Line 1, position 1.
c:\path\to\my\project.json
project.json content:
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
"dependencies": {},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
}
},
"imports": "dnxcore50"
}
}
}
Any ideas?
Turned out that the project.json format is not longer supported. More info here on GitHub.
I am using Visual Studio 2015 and creating a test MVC application.
I have added bower file (bower.json) with code as follows:
{
"name": "asp.net",
"private": true,
"dependencies": {
"jquery": "2.2.3",
"jquery-validation":"1.15.1",
"jquery-validation-unobtrusive": "3.2.5"
},
"resolutions": {
"jquery-validation": ">=1.8"
}
}
When I save the bower.json, it downloads all correctly, but for jquery-validation it does not download the dist folder:
I have an ASP.NET Core application that compiles and runs locally. When I try to restore the nuget packages on Visual Studio Team Services (hosted agent) the following errors occurs:
Ix-Async 1.2.5 is not compatible with .NETPlatform,Version=v5.4.
Remotion.Linq 2.0.1 is not compatible with .NETPlatform,Version=v5.4.
System.Collections.Immutable 1.1.36 is not compatible with
.NETPlatform,Version=v5.4.
Some packages are not compatible with .NETPlatform,Version=v5.4.
Ix-Async 1.2.5 is not compatible with DNXCore,Version=v5.0.
Remotion.Linq 2.0.1 is not compatible with DNXCore,Version=v5.0.
Microsoft.CodeAnalysis.CSharp 1.1.0-rc1-20151109-01 is not compatible
with DNXCore,Version=v5.0.
Microsoft.CodeAnalysis.Common 1.1.0-rc1-20151109-01 is not compatible
with DNXCore,Version=v5.0.
Some packages are not compatible with DNXCore,Version=v5.0.
System.Exception: Unexpected exit code 1 returned from tool NuGet.exe
at
Microsoft.TeamFoundation.DistributedTask.Task.Internal.PowerShell.InvokeToolCmdlet.ProcessRecord()
at System.Management.Automation.CommandProcessor.ProcessRecord()
The VSTS task that is failing is configured like this:
global.json file is as follows:
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-rc1-update1"
}
}
And the project.json file from the web project:
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"AutoMapper": "4.2.1",
"Cubic.Site.Data": "1.0.0-*",
"Cubic.Site.Data.Storage": "1.0.0-*",
"Microsoft.AspNet.Diagnostics": "1.0.0-rc1-final",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.Mvc.Abstractions": "6.0.0-rc1-final",
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
"Microsoft.AspNet.Mvc.ViewFeatures": "6.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Newtonsoft.Json": "8.0.3",
"StyleCop.Error.MSBuild": "1.0.0",
"StyleCop.MSBuild": "4.7.54"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel"
},
"frameworks": {
"dnx451": {
"dependencies": {
}
},
"dnxcore50": { }
},
"exclude": [
"wwwroot",
"node_modules"
],
"publishExclude": [
"**.user",
"**.vspscc"
]
}
The solution contains the web app and 2 other class libraries. Site.Data project.son file:
{
"version": "1.0.0-*",
"description": "Site.Data Class Library",
"authors": [ "foo" ],
"tags": [ "" ],
"projectUrl": "",
"licenseUrl": "",
"frameworks": {
"net451": { },
"dotnet5.4": {
"dependencies": {
"Microsoft.CSharp": "4.0.1-beta-23516",
"System.Collections": "4.0.11-beta-23516",
"System.Linq": "4.0.1-beta-23516",
"System.Runtime": "4.0.21-beta-23516",
"System.Threading": "4.0.11-beta-23516"
}
}
}
}
And the other class library project.json file content is:
{
"version": "1.0.0-*",
"description": "Site.Data.Storage Class Library",
"authors": [ "foo" ],
"tags": [ "" ],
"projectUrl": "",
"licenseUrl": "",
"frameworks": {
"net451": {
"frameworkAssemblies": {
"System.Runtime": ""
}
},
"dotnet5.4": {
"dependencies": {
"Microsoft.CSharp": "4.0.1-beta-23516",
"System.Collections": "4.0.11-beta-23516",
"System.Linq": "4.0.1-beta-23516",
"System.Runtime": "4.0.21-beta-23516",
"System.Threading": "4.0.11-beta-23516"
}
}
},
"dependencies": {
"Cubic.Site.Data": "1.0.0-*",
"EntityFramework.Core": "7.0.0-rc1-final",
"EntityFramework.InMemory": "7.0.0-rc1-final"
}
}
Any idea on what's going on? The strange thing is that the first time this error occurred there were absolutely no changes to config files, project files or the solution - only ASP.NET MVC views were modified. Since that moment I wasn't able to restore the nuget packages on VSTS.
I was wondering if something was installed on the hosted agent that is causing this error?
EDIT 2016-06-21
This issue is now fixed, these errors no longer occur!!! I suspect that there were some changes on the hosted agent that would fix this issue, maybe someone from the VSTS can confirm that??
Since you didn't see this issue anymore, it should be caused by the nuget version in Hosted Build Agent. Refer to this link for details: Issues with Hosted Build in Visual Studio Team Services – 6/20 – Resolved.
Final Update: Tuesday, 21 June 2016 16:07 UTC
Our hotfix deployment to restore nuget 3.3 on the Build Agents has
completed by 21 June 2016 ~03:00 UTC. Customers should no longer see
any issues with running Hosted Builds due to nuget package restore.
We understand that customers rely on VS Team Services as a critical
service and apologize for any impact this incident caused.
Sincerely, Manohar
Update: Monday, 20 June 2016 22:10 UTC
The update to nuget.exe from 3.3 to 3.4.3 has been identified as the
root cause of the active restore problems. We are working on a hotfix
to restore the previous nuget version on the build agents.
We will update this post as the hotfix progresses.
Sincerely, Sri Harsha
Initial Update: Monday, 20 June 2016 19:40 UTC We are actively
investigating issues with the build agents of Visual Studio Team
services related to nuget package restore. Some customers may
experience Build failures due to nuget packages being restored
incorrectly in the Build Agents.
Next Update: Before 22:00 UTC We are actively working to resolve this
issue and apologize for any inconvenience.
Sincerely, Manohar
I have ASP.NET Core project which has both netcoreapp and net46 in frameworks section. I can build and run it without any problem on Mac OS X. But when i open it in VSCode it shows tons of errors like this: Predefined type '...' is not defined or imported [net46] and everything is red.
Is there any way to fix it without removing net46 from project.json?
Frameworks section of my project.json:
"frameworks": {
"net46": {
"dependencies": {
"System.Net.Http": "4.0.0-*"
}
},
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0-*",
"type": "platform"
},
"System.Net.Http": "4.0.1-*"
},
"imports": [
"dnxcore50"
]
}
}
In a Visual Studio 2015 solution I have a folder structure as follows:
-src
-Project.Models
(...)
-MyModel.cs
-Project.Web
(...)
-Controllers
-MyControllers.cs
-Dependencies
-project.json
Where Project.Web is a ASP.NET 5 Web API project and Project.Models a ASP.NET 5 Class Library.
Now I want to use MyModel of Project.Models in MyController of Project.Web. To do this I need to reference the Models project from the Web project. I cannot get this to work here. The using Project.Models statement keeps highlighting the Models part in red because the assembly reference cannot be found.
What I tried:
The usual "Add reference" in combination with using statement
Creating a NuGet package of Project.Models (by specifying "Compile on built" in properties), adding the NuGet package to a local repository and referencing it in project.json.
Both things do not seem to work also after restarting Visual Studio.
Can someone explain to me how to accomplish referencing the Project.Models from Project.Web?
/Edit Include project.json:
{
"webroot": "wwwroot",
"version": "1.0.0-*",
"dependencies": {
"Microsoft.AspNet.Mvc": "6.0.0-beta5",
"Microsoft.AspNet.Server.IIS": "1.0.0-beta5",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta5",
"Microsoft.AspNet.StaticFiles": "1.0.0-beta5",
"Microsoft.AspNet.Loader.IIS": "1.0.0-beta5",
"Microsoft.AspNet.Loader.IIS.Interop": "1.0.0-beta5",
"Microsoft.Framework.Runtime": "1.0.0-beta5",
"Microsoft.AspNet.Mvc.Xml": "6.0.0-beta5",
"MongoDB.Driver": "2.0.1"
},
"commands": {
"web": "Microsoft.AspNet.Hosting --config hosting.ini"
},
"frameworks": {
"dnx451": { }
},
"exclude": [
"wwwroot",
"node_modules",
"bower_components"
],
"publishExclude": [
"node_modules",
"bower_components",
"**.xproj",
"**.user",
"**.vspscc"
]
}
And global.json
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-beta5",
"runtime": "coreclr",
"architecture": "x86"
}
}
The problem was that I was using .NET Core. When I changed my frameworks entry in the project.json file to use
"dnx451": { }
instead of
"dnxcore50": { }
the references were included again (the red of the image became black). Seems like .NET core does not (yet?) support all packages.