I'm trying to execute in a Mac (El Capitán), the MusicStore example in ASP.NET from the official repository.
I have tested it using mono and core, switching in dnvm, but no results. The dnu build is working fine with mono, with core, the build fails.
When I execute dnx web, all works fine, but when I execute the project (firs load), I have a 500 error, with this error:
An unhandled exception has occurred: Unable to resolve service for
type 'Microsoft.Extensions.CompilationAbstractions.ILibraryExporter'
while attempting to activate
'Microsoft.AspNet.Mvc.Razor.Compilation.RoslynCompilationService'.
I have changed all possibilities (Mono and Core), but I have no idea where is the problem... and I have read this question with no results
Project JSON Added
{
"authors": [
"Microsoft"
],
"description": "Music store application on ASP.NET 5",
"version": "1.0.0-*",
"compilationOptions": { "warningsAsErrors": true, "define": [ "DEMO", "TESTING" ] },
"compile": [
"../../shared/**/*.cs"
],
"publishExclude": "*.cmd",
"webroot": "wwwroot",
"dependencies": {
"EntityFramework.InMemory": "7.0.0-*",
"EntityFramework.MicrosoftSqlServer": "7.0.0-*",
"Microsoft.AspNet.Antiforgery": "1.0.0-*",
"Microsoft.AspNet.Authentication.Cookies": "1.0.0-*",
"Microsoft.AspNet.Authentication.Facebook": "1.0.0-*",
"Microsoft.AspNet.Authentication.Google": "1.0.0-*",
"Microsoft.AspNet.Authentication.MicrosoftAccount": "1.0.0-*",
"Microsoft.AspNet.Authentication.OpenIdConnect": "1.0.0-*",
"Microsoft.AspNet.Authentication.Twitter": "1.0.0-*",
"Microsoft.AspNet.Diagnostics.Entity": "7.0.0-*",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-*",
"Microsoft.AspNet.Mvc": "6.0.0-*",
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-*",
"Microsoft.AspNet.Server.IIS": "1.0.0-*",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-*",
"Microsoft.AspNet.Server.WebListener": "1.0.0-*",
"Microsoft.AspNet.Session": "1.0.0-*",
"Microsoft.AspNet.StaticFiles": "1.0.0-*",
"Microsoft.AspNet.Tooling.Razor": "1.0.0-*",
"Microsoft.Extensions.CodeGenerators.Mvc": "1.0.0-*",
"Microsoft.Extensions.Configuration.CommandLine": "1.0.0-*",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-*",
"Microsoft.Extensions.Configuration.Json": "1.0.0-*",
"Microsoft.Extensions.Logging.Console": "1.0.0-*"
},
"commands": {
"gen": "Microsoft.Extensions.CodeGeneration",
"run": "run server.urls=http://localhost:5003",
"web": "Microsoft.AspNet.Server.Kestrel",
"kestrel": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.Kestrel --server.urls http://localhost:5004",
"weblistener": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5002"
},
"frameworks": {
"dnx451": { },
"dnxcore50": {
"dependencies": {
"System.Runtime.Serialization.Primitives": "4.0.10-*"
}
}
}
}
Thanks!!
dnvm list (command result) I have tested with Mono and Core...
Note: Ensure to get the rc1 version of the Music Store
The main process to making the application work once everything is working is to make sure that your runtime is on the latest version of the feed (in this case, Nuget.org).
Nuget.org at the moment is at rc1-final. So you'll need the rc1-final/rc1-update1 to run it properly. (Which is ok for you)
Once this is done, we're ready to restore packages for the application.
dnu restore for the DNX runtime
And in other scenarios (not the MusicStore in this case), you'll need to run npm install and bower install.
Once everything is updated, you can run dnx web at the same level as the project.json and it should run.
Related
I have ASP.NET Core Web API project and .Net Core Library project. The Web API has reference to Library project as target : project. Name of the library project is Transformations.
Below is the project.json for both the projects
project.json for Web API
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0",
"type": "platform"
},
"Microsoft.ApplicationInsights.AspNetCore": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.FileExtensions": "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",
"Transformations": {
"target": "project"
},
"Microsoft.Extensions.DependencyInjection": "1.0.0",
"Serilog.Extensions.Logging": "1.3.0-dev-10125",
"Serilog.Sinks.RollingFile": "3.0.0",
"Serilog.Settings.Configuration": "2.1.0",
"Microsoft.AspNetCore.Diagnostics": "1.0.0"
},
project.json for Library project
{
"version": "1.0.0-*",
"dependencies": {
"NETStandard.Library": "1.6.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0"
},
"frameworks": {
"netstandard1.6": {
"imports": "dnxcore50"
}
},
"configurations": {
"Production": {},
"Staging": {}
}
}
On the build server below is the project structure for Api & Transformation projects.
D:\Jenkins\MyJenkinsProject\workspace\src\MySolution
\Api
\Transformation
On the build server I executed the following commands
D:\Jenkins\MyJenkinsProject\workspace\src\MySolution\Api>dotnet restore
and then
D:\Jenkins\MyJenkinsProject\workspace\src\MySolution\Api>dotnet build
I get error
Project Transformations does not have a lock file. Please run
"dotnet restore" to generate a new lock file.
Now if I run the following the following commands in the order, then everything works fine.
D:\Jenkins\MyJenkinsProject\workspace\src\MySolution\Transformation>dotnet restore
D:\Jenkins\MyJenkinsProject\workspace\src\MySolution\Api>dotnet restore
D:\Jenkins\MyJenkinsProject\workspace\src\MySolution\Api>dotnet build
Questions
1>When library is referenced as project in API project why do I need to run dotnet restore separately for library project? Why cant it restores referened project implicitly?
From Zlatko Knezevic:
This behavior is by design. […] If you wish to restore all of the dependencies for all your projects in one go, so to speak, just run dotnet restore at the root of your solution (where you have the global.json file).
i believe you can just do a dotnet build directly. it should automatically do a dotnet restore.
I am creating a new ASP.NET Core project using dotnet 4.5.2 and am trying to add a reference to Microsoft.EntityFrameworkCore.Tools. In my project.json file I have these listed under dependencies:
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.0",
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final"
Looking under References, they appear to be successfully loaded. I then added this under tools in project.json:
"Microsoft.EntityFrameworkCore.Tools": {
"imports": [ "portable-net451+win8" ],
"version": "1.0.0-preview2-final"
}
After I added that, when I build the solution I get this build error:
Could not find a part of the path 'C:\Users\(my user name)\.nuget\packages\.tools\Microsoft.EntityFrameworkCore.Tools'
I get the same error if I remove the imports line. What am I doing wrong here?
Just ran into the same issue.
I fixed the issue by installing the tools package again in the package manager console:
Install-Package Microsoft.EntityFrameworkCore.Tools –Pre
Before reinstalling the package was actually missing in the .nuget\packages.tools folder, after reinstalling it was there.
I followed the https://docs.efproject.net/en/latest/platforms/aspnetcore/new-db.html tutorial, but I think I installed the package in the wrong order or initially forgot to reference the EF.tools package in the "tools" section of the project json.
I had this same problem and just solved using the examples from the EF Core setup guide from Microsoft, checking their GitHub code as well, I found this to work for the project.json.
I had to remove the imports from the "frameworks" property, which means no Application Insights for now. Once I did this and built, the folder appeared in the tools folder. Sorry I'm not good at posting code here but here are the important parts, ... elipses used to trim the post of my other things:
"dependencies": {
...
"Microsoft.EntityFrameworkCore": "1.0.0",
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.0",
"Microsoft.EntityFrameworkCore.SqlServer.Design": "1.0.0",
"Microsoft.EntityFrameworkCore.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
} ...},
"tools": {
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
},
"frameworks": {
"netcoreapp1.0": {
}...
I had the same issue and had to add the following to my project.json.
"Microsoft.EntityFrameworkCore.SqlServer.Design": "1.1.0-preview1-final"
The only difference is that I'm working with the newly release .NET Core 1.1, ASP.NET 1.1 and Entity Framework 1.1.
I had the same issue and tried many things. I found out that Design and Tools need to be the same version but intellisense was not giving me options common to both packages. Then I found this article and tried its code.
https://learn.microsoft.com/en-us/ef/core/miscellaneous/cli/dotnet
Using the following code from that article solved the issue for me;
"dependencies": {
"Microsoft.EntityFrameworkCore.Design": {
"type": "build",
"version": "1.0.0-preview2-final"
}
"Microsoft.EntityFrameworkCore.Tools": {
"type": "build",
"version": "1.0.0-preview2-final"
},
},
...
"tools": {
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final"
},
My problem was I had Microsoft.EntityFrameWorkCore.Tools instead of Microsoft.EntityFramework.Tools, note the lowercase w.
I created a new "ASP.NET Core Web Application (.NET Core)" project in VS2015. It built without any issues, so I thought to give it a test run. However, when starting up, it choked and crashed with the following error:
Exception thrown: 'System.AggregateException' in Microsoft.AspNetCore.Server.Kestrel.dll
The program '[11608] dotnet.exe' has exited with code -1073741819 (0xc0000005) 'Access violation'.
The program '[15048] iisexpress.exe' has exited with code 0 (0x0).
I don't see anything else logged. I tried debugging it, and all I found out was that it broke during the WebHostBuilder.Run() method in Program class. It is part of the framework, so I wasn't able to get much further.
Note that the program runs fine when running via dotnet run command. Only IISExpress does not work.
How should I go about debugging this issue?
The project.json file is below. (It was generated by Visual Studio, I did not change anything.)
{
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0-rc2-3002702",
"type": "platform"
},
"Microsoft.AspNetCore.Diagnostics": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.0.0-preview1-final",
"type": "build"
},
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final",
"Microsoft.AspNetCore.StaticFiles": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-final",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc2-final"
},
"tools": {
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.0.0-preview1-final",
"imports": "portable-net45+win8+dnxcore50"
},
"Microsoft.AspNetCore.Server.IISIntegration.Tools": {
"version": "1.0.0-preview1-final",
"imports": "portable-net45+win8+dnxcore50"
}
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"dnxcore50",
"portable-net45+win8"
]
}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"runtimeOptions": {
"gcServer": true
},
"publishOptions": {
"include": [
"wwwroot",
"Views",
"appsettings.json",
"web.config"
]
},
"scripts": {
"prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ],
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}
Update: I created a new project for the Core RTM release, and this time it worked.
The other issue is that you might be running an old version of the framework. Try going to the root (project.json) location of your runnable project and in a Command Prompt type:
dotnet run
I had the same problem as you. For me the solution was to close VS2015, delete the file project.lock.json and then restart VS again. (project.lock.json will be generated automatically)
It looks like the debugger cannot attach to the application. In my case I added a throw new Exception("..."); in the first line of the function public Startup(IHostingEnvironment env) and the application just dies and doesn't break on the unhandled exception as expected.
After project.lock.json was rebuilt the debugger works fine again.
I updated to the RTM release of dotnet core and creating a new project using the new version worked. I guess it must be a bug.
For those bumping into this, I had the same exactly behavior and error message as described in the question.
Apparently there are some terms that can't solely be used as the project name, such as web or app. (I fixed it renaming my project to WebApp)
It was already logged as a bug and the fix will be included in the upcoming releases.
Unfortunately, after the first failed run, a project rename isn't enough to make it work, since the IIS Express config file keeps the old entry.
Just edit the applicationhost.config file located at [PROJECT_ROOT]\.vs\config\ and remove the site element that is named web or app, restart VS and run it.
Hope it helps!
I've got the same error when I run my project (not using IIS).
After some investigation I found out that server url in appsettings.json (which using in Configuration) was already busy. I changed url and it worked well.
Hope it helps somebody!
I had the same error. The solution is found was that my x64 app was set to build as x86
I am using:
.NET Command Line Tools (1.0.0-rc2-002439)
Product Information:
Version: 1.0.0-rc2-002439
Commit Sha: ef0c3b2cee
Runtime Environment:
OS Name: Windows
OS Version: 10.0.10586
OS Platform: Windows
RID: win10-x64
and getting:
error CS0121: The call is ambiguous between the following methods or properties: 'Microsoft.Extensions.DependencyInjection.OptionsServiceCollectionExtensions.Configure(Microsoft.Extensions.DependencyInjection.IServiceCollection, System.Action)' and 'Microsoft.Extensions.DependencyInjection.OptionsServiceCollectionExtensions.Configure(Microsoft.Extensions.DependencyInjection.IServiceCollection, System.Action)'
I suspect there are multiple OptionsModel assemblies (different versions) included on "dotnet restore".
The proof may be here:
The second suggestion with different parameter name:
Project.lock.json file has few interesting lines ("Infrastructure" is a referenced assembly):
"Infrastructure/1.0.0": {
"type": "project",
"framework": ".NETFramework,Version=v4.6.1",
"dependencies": {
"Domain": "1.0.0",
"Microsoft.Extensions.Caching.Abstractions": "1.0.0",
"Microsoft.Extensions.OptionsModel": "1.0.0",
"Newtonsoft.Json": "8.0.3",
"WindowsAzure.Storage": "6.2.1"
},
"compile": {
"net461/Infrastructure.dll": {}
},
"runtime": {
"net461/Infrastructure.dll": {}
}
}
while the web application uses Microsoft.Extensions.OptionsModel/1.0.0-rc2-15914
Here is the configuration section of Infrastructure assembly:
"dependencies": {
"Domain": "1.0.0-*",
"Microsoft.Extensions.Caching.Abstractions": "1.0.0-*",
"Microsoft.Extensions.OptionsModel": "1.0.0-*",
"Newtonsoft.Json": "8.0.3",
"WindowsAzure.Storage": "6.2.1-*"
}
The question is: why different versions (1.0.0 and 1.0.0-rc2-15914) are chosen while executing "dotnet restore"?
UPDATE: I tried changing project.json of Infrastructure project to "Microsoft.Extensions.OptionsModel": "1.0.0-rc2-15914" but I am still can't compile because of ambiguity displayed in screenshots. Are any assemblies cached somewhere on my computer?
The solution is:
Microsoft.Extensions.Options instead of Microsoft.Extensions.OptionsModel package had to be used in a referenced project.
I am attempting to use dotnet restore on a dotnet core project, and it seems to work fine until the very end, when I suddenly get this weird message.
error: System.IO.IsolatedStorage 4.0.1-beta-23516 provides a
compile-time reference assembly for System.IO.IsolatedStorage on
DNXCore,Version=v5.0, but there is no run-time assembly compatible
with win7-x64.
error: System.IO.IsolatedStorage 4.0.1-beta-23516 provides a
compile-time reference assembly for System.IO.IsolatedStorage on
DNXCore,Version=v5.0, but there is no run-time assembly compatible
with win7-x86.
I have searched high and low for answers to this, but I'm totally lost. I've posted my project.json below for reference, as well as my nuget.config feeds.
nuget.config feeds
<packageSources>
<add key="aspnet-core" value="https://www.myget.org/F/aspnetcidev/api/v3/index.json" />
<add key="api.nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
</packageSources>
project.json
{
"webroot": "wwwroot",
"version": "1.0.0-*",
"dependencies": {
"Microsoft.NETCore.Platforms": "1.0.1-*",
"Microsoft.AspNetCore.Diagnostics": "1.0.0-*",
"Microsoft.AspNetCore.IISPlatformHandler": "1.0.0-*",
"Microsoft.AspNetCore.Mvc": "1.0.0-*",
"Microsoft.AspNetCore.Mvc.TagHelpers": "1.0.0-*",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*",
"Microsoft.AspNetCore.StaticFiles": "1.0.0-*",
"Microsoft.Extensions.Configuration.Json": "1.0.0-*",
"Microsoft.Extensions.Logging.Console": "1.0.0-*",
"Microsoft.AspNetCore.Identity": "1.0.0-*"
},
"frameworks": {
"dnx451": {
"dependencies": {
"Microsoft.AspNetCore.Mvc.Dnx": "1.0.0-*"
}
},
"net451": { },
"dnxcore50": {
"imports": "portable-net451+win7+win8",
"dependencies": {
"NETStandard.Library": "1.0.0-*"
}
}
},
"publishExclude": [
"node_modules",
"bower_components",
"**.xproj",
"**.user",
"**.vspscc"
],
"exclude": [
"wwwroot",
"node_modules",
"bower_components"
]
}
Update
I have cleared the following directories;
%userprofile%\.nuget
%userprofile%\.dnx\packages
%localappdata%\NuGet\v3-cache
Then I ran the updater at /scripts/obtain/ from the dotnet/cli/ repository with the following command...
.\install.ps1 -channel beta
Then I went back and did dotnet restore on my project, it does say that it worked, but I get the following warning.
warn : Detected package downgrade: Microsoft.Dnx.Compilation.CSharp.Abstractions from 1.0.0-rc2-16553 to 1.0.0-rc2-16552
Is there anything I can do about that?
Your project looks totally fine and it restores without errors:
log : Restore completed in 69790ms.
NuGet Config files used:
D:\Temp\tempmvc\NuGet.Config
C:\Users\victor\AppData\Roaming\NuGet\NuGet.Config
Feeds used:
https://www.myget.org/F/aspnetcidev/api/v3/index.json
https://api.nuget.org/v3/index.json
https://www.nuget.org/api/v2/
Installed:
279 package(s) to D:\Temp\tempmvc\project.json
You might have some newer packages from other feeds in the packages caches or you might be using the wrong version of dotnet cli. Make sure you install the CLI from the beta channel.
To clear the caches delete:
%userprofile%\.nuget
%localappdata%\NuGet\v3-cache
To install the CLI from the beta feed, run the script from here:
install.ps1 -channel beta
The above answer is no longer valid with respect to the install.ps1 statement, but I cannot comment there:
The script name is now dotnet-install.ps1 and the parameters for channel are now: future, preview, and production with production being the most stable.
i.e.
dotnet-install.ps1 -channel production
EDIT: well for the moment -channel beta does still work and production does not exist yet, despite being listed in the source code :) the joys of pre-release software...