Closed Bartmax closed 6 years ago
just remember one undocumented note:
i deleted .dnx
folder at some point and app stopped working.
it was fixed with dnvm install/upgrade
not sure exactly what was the problem... and don't remember clearly.
one more undocumented note:
IFormFile.SaveAsync
was removed because it was impossible to test. https://github.com/aspnet/HttpAbstractions/issues/610
We added what we found on old source code:
public static class FormFileExtensions
{
private static int DefaultBufferSize = 80 * 1024;
/// <summary>
/// Asynchronously saves the contents of an uploaded file.
/// </summary>
/// <param name="formFile">The <see cref="IFormFile"/>.</param>
/// <param name="filename">The name of the file to create.</param>
public async static Task SaveAsAsync(
this IFormFile formFile,
string filename,
CancellationToken cancellationToken = default(CancellationToken))
{
if (formFile == null)
{
throw new ArgumentNullException(nameof(formFile));
}
using (var fileStream = new FileStream(filename, FileMode.Create))
{
var inputStream = formFile.OpenReadStream();
await inputStream.CopyToAsync(fileStream, DefaultBufferSize, cancellationToken);
}
}
}
Nice feedback. What was your experience with EntityFramework tooling after upgrading? Are you able to do migrations/scaffolding and everything as expected? I hit a roadblock with "ef dbcontext scaffold" and had to revert back to the DEC 2015 builds of RC2 but maybe I'm an anomaly.
@kudoz83 I had no issues, i just did 1 migration dotnet ef migrations add
... and went back to rc1 because of not being able to save and refresh.
Any problems using VS2015. Any tooling or debugging issues you ran into. Or does the Asp.net RC1 tooling installer still work.
@cvs79 no tooling for you sir. They are working on the tooling side, but those weren't released yet. Most notably Intellisense on razor pages is broken :(
Thanks for the complete nice feedback. I was planning to migrate my own project from RC1 to RC2, this will help me for sure!
This is good.
Also the ASPNET_ENV
/Hosting:Environment
moniker has changed to ASPNETCORE_ENVIRONMENT
I am enjoying the positive vibe here. Have no active projects and some time on my hands so let me know if anyone needs me to try anything out and offer feedback.
Added "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0-rc2-*"
to our project.json
to get the 'POCO configuration binding' extension methods back.
@tuespetre thank you! I'll give it a try!
@tuespetre I am using the Microsoft.Extensions.Configuration.Binder
package to get the binder extension methods. I could not find Microsoft.Extensions.Options.ConfigurationExtensions
on the aspnetcirelease
feed; are you sure that's the right package name?
I don't know about aspnetcirelease
, but it is there on aspnetvnext
and aspnetcidev
.
What's going to be easier for me in the long run... updating now in this sort of tumultuous state from RC1, or waiting a while?
@twilliamsgsnetx if you use Visual Studio, wait a few more days...
if you use VS Code i guess it's ok to update now.
just my personal opinion. It's always up to you to balance the pro/cons.
Yeah I have a site currently in production that is using many aspecst... mvc, identity, entity. And I am using Visual Studio as well. I'll give it a shot.
Well I worked out all the hundreds of errors. @Bartmax guide really helped in some areas. Others required some researching. This really helped me for tons of the errors regarding System.RunTime
https://github.com/aspnet/dnx/issues/2334
Doesn't actually seem to want to run however... so still some more research to be done. Just spins and spins. I'm actually currently on 1.0.0-rc3-20550
When trying to dotnet run
Unhandled Exception: System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested etrieve the LoaderExceptions property for more information. at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module) at System.Reflection.RuntimeAssembly.get_DefinedTypes() at Microsoft.AspNetCore.Hosting.Internal.ServerLoader.ResolveServerFactoryType(String assemblyName) at Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildHostingServices() at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build() at DataPlatform.Startup.Main(String[] args) in C:\Github\Data-Platform\src\DataPlatform\Startup.cs:line 124
Wait there's already an RC3 build? I still cannot manage to migrate to RC2 from RC1
I got
error CS7069: Reference to type 'IFormFile' claims it is defined in 'Microsoft.AspNetCore.Http.Abstractions', but it could not be found
@dodyg No, there is no RC3 build; however, there are RC3 packages. The word on the street is that there will not be an RC3 release at all; this is merely being done to hold packages under development but that need to be kept off of RC2 stabilization for RC2 release. They get pulled into your app depending on which feeds you're using. If you stick with the CI Release feed right now, you will only get RC2 packages even when you make your deps -*
(as opposed to having to -rc2-*
them). If you want to use other feeds with RC3 packages on them but limit dependencies to RC2, then go with -rc2-*
versions.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="AspNetCI" value="https://www.myget.org/F/aspnetcirelease/api/v3/index.json" />
<add key="NuGet.org" value="https://api.nuget.org/v3/index.json" />
</configuration>
Thanks for the tips. Let me try this migration thing one more time.
Well...I think I'm not gonna update to RC2 anytime soon!
Well... to be fair... RC2 is still "in-development" and is still not stable with the new dotnet-cli.
Even the team itself had trouble creating a "working experience" a few weeks ago with all the pieces.
If you want to be in the meat grinder and see how the sausage is made? Try RC2! You'll find full of issues and help the team improve ASP.NET by finding bugs and everything. That's what "devbuild" and "nightlies" are for.
Just want to build software on something stable? Back to RC1. :smiley:
What would this be in the RC 2
"frameworks": {
"dnx451": {
"frameworkAssemblies": {
"System.ComponentModel": "4.0.0.0"
}
}
},
I want to target .NET 4.5/4.6. I am using packages that only work on Windows.
Now I hit this bug https://github.com/NuGet/Home/issues/2644
OK I fixed https://github.com/NuGet/Home/issues/2644 by adding imports statement.
"tools": {
"dotnet-publish-iis": {
"version": "1.0.0-*",
"imports":["portable-net40+sl5+win8+wp8+wpa81"]
},
"dotnet-ef": {
"version": "1.0.0-*",
"imports":["portable-net40+sl5+win8+wp8+wpa81"]
},
"dotnet-watch": {
"version": "1.0.0-*",
"imports":["portable-net40+sl5+win8+wp8+wpa81"]
},
"dotnet-razor-tooling": {
"version": "1.0.0-*",
"imports":["portable-net40+sl5+win8+wp8+wpa81"]
}
},
I got it to compile yay! until I hit this https://github.com/aspnet/EntityFramework/issues/5076 and this https://github.com/aspnet/Announcements/issues/167
Now I got this problem regarding TagHelpers
Connection id "0HKRFAFEBCLGM": An unhandled exception was thrown by the application.
Microsoft.AspNetCore.Mvc.Razor.Compilation.CompilationFailedException: One or more compilation failures occurred:
Error @ (164:5,17)(31) - [Cannot resolve TagHelper containing assembly 'Microsoft.AspNet.Mvc.TagHelpers'. Error: Could not load file or assembly 'Microsoft.AspNet.Mvc.TagHelpers' or one of its dependencies. The system cannot find the file specified.] (5,17) Cannot resolve TagHelper containing assembly 'Microsoft.AspNet.Mvc.TagHelpers'. Error: Could not load file or assembly 'Microsoft.AspNet.Mvc.TagHelpers' or one of its dependencies. The system cannot find the file specified.
I fixed it by changing
@addTagHelper "*, Microsoft.AspNet.Mvc.TagHelpers"
to
@addTagHelper "*, Microsoft.AspNetCore.Mvc.TagHelpers"
from _ViewImports.cshtml
I GOT IT WORKING!!! At least a home page. :fireworks: :fireworks: :fireworks: :joy:
I was making good progress on my own upgrade until I hit dotnet/cli@2429: Object reference not set to an instance of an object
. No luck getting around it yet.
This is my project.json http://pastebin.com/KTrXnFSX
@dodyg - you seem to be using tools so you may want take a look at this announcement: https://github.com/aspnet/Announcements/issues/172
What is the dotnet command that allows to run an aspnet project with a certain HostingEnvironment variable?
dotnet run
runs my project in production environment.
My Main is
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseStartup<Startup>()
.Build();
host.Run();
}
What I want to get is the edit code and refresh functionality that existed on RC1.
I think environment has always been based on an environment variable. So you would have to set ASPNETCORE_ENVIRONMENT
before running.
The problem is that dotnet run
does not seem to pick up the profile.
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:49948/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sdkVersion": "dnx-clr-win-x64.1.0.0-rc2-16595"
},
"web": {
"commandName": "web",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sdkVersion": "dnx-clr-win-x64.1.0.0-rc2-16595"
}
}
}
Found it
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseKestrel()
.UseEnvironment("Development")
.UseContentRoot(Directory.GetCurrentDirectory())
.UseStartup<Startup>()
.Build();
host.Run();
}
The problem is the edit and refresh is still not working - it will investigate dotnet watch
I hit this one with dotnet watch https://github.com/aspnet/dotnet-watch/issues/88
What is the new procedure on hosting with IIS ? dotnet publish
does not exactly publish the files properly for a web app.
dotnet publish-iis
returns
Expected to load hostpolicy.dll from [C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.0.0-rc2-3002520]
This may be because the targeted framework ["Microsoft.NETCore.App": "1.0.0-rc2-3002520"] was not found.
@dodyg I'm working on the new guidance today. You can see a draft of it here: https://github.com/GuardRex/Docs/blob/master/aspnet/publishing/iis.rst ... that should help. The Troubleshooting bits are being developed here: https://github.com/aspnet/Docs/issues/1140#issuecomment-215612619
dotnet publish
(perhaps better stated as dotnet publish --configuration Release
since it defaults to "Debug") will produce outputs for a portable application that requires you to install .NET Core on the server for it to run. Therefore, you will not see an executable in the publish
folder outputs. If you mod the app with an RID (runtime id) and mod the dep for Microsoft.NETCore.App
and drop the "type": "platform"
, you can publish with dotnet publish --configuration Release --runtime <RID>
and get a self-contained app that will have an executable. You can learn more at: https://github.com/blackdwarf/core-docs/blob/clidocs/docs/core-concepts/app-types.md
@GuardRex thanks but I think my problem is more mundane. I am targeting net451 because I rely on some .NET 4.6 library.
The problem is I can't even get dotnet publish-iis
to work with this net451 TFM https://github.com/aspnet/Home/issues/1381#issuecomment-215749537
@dodyg publish-iis
is a tool that merely deals with web.config
... do you mean dotnet publish
? publish-iis
is not meant to actually publish your project.
@GuardRex
Got it. dotnet publish
(publish-iis
fails though) works although the output is strange. None of the css, js, etc, are actually available in the publish folder (http://imgur.com/GbK5sUE)
@dodyg How does publish-iis fail?
cc @moozzyk
Yes, if you wanted to use the publish-iis
tooling to generate or modify your web.config
file (which is all it is going to do for you), you would add this to your project.json
and then do a dotnet restore
followed by a dotnet publish --configuration Release
...
"scripts": {
"postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%"
},
"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": {
"version": "1.0.0-*",
"imports": "portable-net45+wp80+win8+wpa81+dnxcore50"
}
},
The publish-iis
tooling will create your web.config
for you if it isn't in the root of your project. If it is in the root of your app, then it will modify the processPath
and arguments
and put the file in your published output.
For actually publishing a .NET Core app, you truly use dotnet publish
as the command. You don't need that tooling. You can just manually have a web.config
file in your project root and specify that it should be copied on publish. This has been accomplished by having a content
section in project.json
. See the cli-samples at https://github.com/aspnet/cli-samples. [Note: content
is being changed to publishOptions
, so keep an eye on the samples.]
@muratg I think he's just confused and thought that the publish-iis
tooling would actually publish his project.
@muratg on the following project.json (http://pastebin.com/tuqB6Lf2)
Expected to load hostpolicy.dll from [C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.0.0-rc2-3002520]
This may be because the targeted framework ["Microsoft.NETCore.App": "1.0.0-rc2-3002520"] was not found.
I am using
.NET Command Line Tools (1.0.0-rc2-002498)
Product Information:
Version: 1.0.0-rc2-002498
Commit Sha: 55e561bfb3
Runtime Environment:
OS Name: Windows
OS Version: 10.0.10586
OS Platform: Windows
RID: win10-x64
Your dotnet cli
is old. Update to latest: https://github.com/dotnet/cli/tree/rel/1.0.0
^^ and you're missing ...
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0-*"
}
... from your dependencies.
^^ and your content
section should explicitly state the outputs you want copied over to published output. For example, here's one of mine ...
"content": [
"Views",
"wwwroot",
"Logs"
],
Note: Keep in mind that that is about to change. Keep an eye on the samples ... it will be changing to publishOptions
soon ... perhaps even today! :smile:
Let's try this again :smile:
Adding Microsoft.NETCore.App
generates torrents of error message (This is the project.json file http://pastebin.com/sFHCnC62) for my net451
target.
These are the error messages http://pastebin.com/pLLvPn6q.
Microsoft.NETCore.App
relies on some packages that are not compatible with net451
.
The question is what kind of TFM can I use instead of net45
.
When I tried to use .netstandard1.5
, it generates the following errors:
Errors in E:\labs\crucible\trunk\crucible.web\project.json
Package CommonMark.NET 0.11.0 is not compatible with netstandard1.5 (.NETStandard,Version=v1.5). Package CommonMark.NET 0.11.0 supports:
- dnxcore50 (DNXCore,Version=v5.0)
- net20 (.NETFramework,Version=v2.0)
- net35-client (.NETFramework,Version=v3.5,Profile=Client)
- net40-client (.NETFramework,Version=v4.0,Profile=Client)
- net45 (.NETFramework,Version=v4.5)
- portable-net40+sl5+win8+wp8+wpa81 (.NETPortable,Version=v0.0,Profile=Profile328)
- portable-net45+win8+wp8+wpa81 (.NETPortable,Version=v0.0,Profile=Profile259)
Package Nustache 1.15.3.7 is not compatible with netstandard1.5 (.NETStandard,Version=v1.5). Package Nustache 1.15.3.7 supports: net20 (.NETFramework,Version=v2.0)
Package Microsoft.Dnx.Compilation.CSharp.Common 1.0.0-rc2-20221 is not compatible with netstandard1.5 (.NETStandard,Version=v1.5). Package Microsoft.Dnx.Compilation.CSharp.Common 1.0.0-rc2-20221 supports:
- dotnet5.4 (.NETPlatform,Version=v5.4)
- net451 (.NETFramework,Version=v4.5.1)
Package Microsoft.Dnx.Compilation.CSharp.Abstractions 1.0.0-rc2-20221 is not compatible with netstandard1.5 (.NETStandard,Version=v1.5). Package Microsoft.Dnx.Compilation.CSharp.Abstractions 1.0.0-rc2-20221 supports:
- dotnet5.4 (.NETPlatform,Version=v5.4)
- net451 (.NETFramework,Version=v4.5.1)
Package Microsoft.Extensions.PlatformAbstractions.Dnx 1.0.0-rc2-20221 is not compatible with netstandard1.5 (.NETStandard,Version=v1.5). Package Microsoft.Extensions.PlatformAbstractions.Dnx 1.0.0-rc2-20221 supports:
- dotnet5.4 (.NETPlatform,Version=v5.4)
- net451 (.NETFramework,Version=v4.5.1)
Package Newtonsoft.Json 8.0.3 is not compatible with netstandard1.5 (.NETStandard,Version=v1.5). Package Newtonsoft.Json 8.0.3 supports:
- net20 (.NETFramework,Version=v2.0)
- net35 (.NETFramework,Version=v3.5)
- net40 (.NETFramework,Version=v4.0)
- net45 (.NETFramework,Version=v4.5)
- portable-dnxcore50+net45+win8+wp8+wpa81 (.NETPortable,Version=v0.0,Profile=net45+wp80+win8+wpa81+dnxcore50)
- portable-net40+sl5+win8+wp8+wpa81 (.NETPortable,Version=v0.0,Profile=Profile328)
Package Ix-Async 1.2.5 is not compatible with netstandard1.5 (.NETStandard,Version=v1.5). Package Ix-Async 1.2.5 supports:
- net40 (.NETFramework,Version=v4.0)
- net45 (.NETFramework,Version=v4.5)
- portable-net45+win8+wp8 (.NETPortable,Version=v0.0,Profile=Profile78)
Package Remotion.Linq 2.0.2 is not compatible with netstandard1.5 (.NETStandard,Version=v1.5). Package Remotion.Linq 2.0.2 supports:
- net35 (.NETFramework,Version=v3.5)
- net40 (.NETFramework,Version=v4.0)
- net45 (.NETFramework,Version=v4.5)
- portable-net45+win8+wp8+wpa81 (.NETPortable,Version=v0.0,Profile=Profile259)
One or more packages are incompatible with .NETStandard,Version=v1.5.
My CLI is now up to date
.NET Command Line Tools (1.0.0-rc2-002543)
Product Information:
Version: 1.0.0-rc2-002543
Commit Sha: 38d0c28a1e
Runtime Environment:
OS Name: Windows
OS Version: 10.0.10586
OS Platform: Windows
RID: win10-x64
IIRC netstandard1.5
was not designed (or the design was changed) such that even if you have emitEntryPoint
it will not produce runnable output (it's the TFM for libraries). The TFM for Core apps would ordinarily be netcoreapp1.0
; however, that won't be the TFM you are targeting. You are targeting the .NET Framework, so you should be targeting net45
(or net4x
/net4xy
to be more specific). I'm sure @muratg can help more with that TFM than I can, as I'm a 100% Core CLR cat. However, if Murat is busy and doesn't get back to you, I'll pull down your project.json
here in a few hours and see what's what. I've gotten pretty good at :monkey: banging :monkey: on the keyboard until an app will restore ... although compiling and running is another story. :smile:
Yeah netstandard*
is for libraries, and netcoreapp*
is for CoreCLR apps.
For full desktop apps, use net452
minimum.
@muratg
Damn, that's the secret, net452
instead of net451
and now everything works (dotnet watch, dotnet publish-iis, dotnet ef```)
@davidfowl asked me for notes so here they are. You may want to scroll down to the pain points section below :)
Migration RC1 to RC2
Easy/expected changes:
Tools
install RC2 tooling. The lastest tools can be found here: https://github.com/dotnet/cli We first started with https://dotnet.github.io/getting-started/ but it's outdated.
global.json
Update version of global.json to match RC2
Nuget.config
add ci builds to nuget config
project.json
Dependencies
Update all dependencies from
Microsoft.AspNet.xxx
toMicrosoft.AspNetCore.xxx
exceptMicrosoft.AspNet.WebApi.Client
Update all dependencies from
x.EntityFramework.x
tox.EntityFrameworkCore.x
Downgrade version to 1.0 on all dependencies renamed.Some package rename were by hand because it wasn't a straight convention,
Microsoft.AspNetCore.Diagnostics.Entity
Microsoft.EntityFrameworkCore.SqlServer
Some low-impact packages were removed:
Microsoft.VisualStudio.Web.BrowserLink.Loader
External dependency
Moq
changed package nameFrameworks
Update TFM. This change was a complete copy paste of some sample code. We had no idea what this change means. before:
after:
Code Changes
NOTE:
BEFORE
code may contain AspNetCore because of the initial rename of allusing
directive.Usings
Rename all using directives in .cs, .cshtml Find all and replace:
using Microsoft.AspNet.
->using Microsoft.AspNetCore.
About 122 occurrence(s).Controllers
Entity Framework
GraphBehavior.X does not exist anymore on EF context methods.
Extensions
Identity
User.GetUserId()
andUser.IsSignedIn()
doesn't exist. it was removed and added toUserManager
andSignInManager
.ExternalLoginInfo.ExternalPrincipal
was renamed toExternalLoginInfo.Principal
Startup
This change is a complete copy/paste from sample. No idea what's going on here.
Pain points:
DotNet Restore
This was executed multiple times, at different point of migration. Mostly all the output was kinda useless. Too much information, to many unknowns. We tried to switch to -v warning with no luck. It took some time to get to -v Minimal to get a usefull output from dotnet restore.
App Settings
We found a runtime Error with regarding appsettings. The error was clear, the options available not. The fix was to change Verbose to Information
We used POCO Configuration with code like:
we dig into lots of documents, code, issues. We hope this would be on Announcements repo but we couldn't find it. we ended up with a hack
Code
Some inner workings of razor,views,engines,etc changes weren't mentioned anywhere. We have a simple taghelper that render partial views, this was impossible to figure out how to update it. NTaylorMullen helped there.
Compile success!
Great, right... right?
Environment
Visual Studio environment variable wasn't respected. We first thought that
ConfigureDevelopment
were removed. The problem here was that dotnet run shows the enviroment but an error was throw before. Also this environment variable was changed twice for RC2. The announcement issue shows the old one with a note at the bottom that was changed again. We wasted lot of time dealing with environment. mostly because of not understading the problem straight.cshtml
@inject namespaces had to be renamed, taghelpers, etc. because this was after hitting a specific page it was more painful than the cs code. we also lost intellisense so... we had to rely on error messages.
tooling
We literally copy pasted every tooling sample until we got this:
We still have no idea how those exactly works. The only one that was really needed was EF because migrations (see next point). We tried for several hours to get
dotnet-watch
to run without success.EF Changes
I hit this issue: Invalid object name 'TableName' before an announcement were created here: EF Core: Table names now taken from DbSet names (starting in RC2).
While it was a simple ask repo and got a solution very quickly, it was like a neverending error trip. At this point we were tired.
... And runs! ..., almost
we hit the web application but we seen no static files served! DAMN! We looked everywhere until we figure out that no gulp build was executed! even we had that on
prepublish
. and well.. thenit worked.