2017-08-21 2 views
5

Après la mise à niveau vers .NET Core 2.0, mon application Web 1.1 ne peut pas s'exécuter. Je reçois le message d'erreur indiqué ci-dessous. Après avoir vérifié la sortie, j'ai trouvé des références à l'erreur RZ3007 qui, je crois, est liée au compilateur Razor. La vue ne compile pas.Erreur RZ3007: le nom de la balise cible ne peut pas être nul ou blanc

Accueil/Index.cshtml:

@model LayoutViewModel 
<div></div> 

vues/Shared/_Layout.cshtml

<!DOCTYPE html> 
<html> 
<head> 
    <meta charset="utf-8" /> 
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /> 
    <title>@ViewData["Title"] - GLCoderConfiguration</title> 

    <environment names="Development"> 
     <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" /> 
     <link rel="stylesheet" href="~/css/site.css?" /> 
    </environment> 
    <environment names="Staging,Production"> 
     <link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/css/bootstrap.min.css" 
       asp-fallback-href="~/lib/bootstrap/dist/css/bootstrap.min.css" 
       asp-fallback-test-class="sr-only" asp-fallback-test-property="position" asp-fallback-test-value="absolute" /> 
     <link rel="stylesheet" href="~/css/site.min.css?" asp-append-version="true" /> 

    </environment> 
</head> 
<body> 
    <nav class="navbar navbar-default navbar-form " > 

     <div class="navbar-header" style="margin-top:10px;margin-bottom:15px;"> 
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> 
       <span class="sr-only">Toggle navigation</span> 
       <span class="icon-bar"></span> 
       <span class="icon-bar"></span> 
       <span class="icon-bar"></span> 
      </button> 
      <a class="navbar-brand" href="#">SCM - NCMain</a> 
     </div> 


     <div class="collapse navbar-collapse vcenter" id="bs-example-navbar-collapse-1" style="margin-top:10px;margin-bottom:0px;"> 

     </div> 
    </nav> 
    <div class="container body-content"> 
     @RenderBody() 
     <hr /> 
     <footer> 
      <p>&copy; 2017 - England Logisitics - SCM</p> 
     </footer> 
    </div> 

    <environment names="Development"> 
     <script src="~/lib/jquery/dist/jquery.js"></script> 
     <script src="~/lib/bootstrap/dist/js/bootstrap.js"></script> 
     <script src="~/js/site.js" asp-append-version="true"></script> 
    </environment> 
    <environment names="Staging,Production"> 
     <script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-2.2.0.min.js" 
       asp-fallback-src="~/lib/jquery/dist/jquery.min.js" 
       asp-fallback-test="window.jQuery" 
       crossorigin="anonymous" 
       integrity="sha384-K+ctZQ+LL8q6tP7I94W+qzQsfRV2a+AfHIi9k8z8l9ggpc8X+Ytst4yBo/hH+8Fk"> 
     </script> 
     <script src="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/bootstrap.min.js" 
       asp-fallback-src="~/lib/bootstrap/dist/js/bootstrap.min.js" 
       asp-fallback-test="window.jQuery && window.jQuery.fn && window.jQuery.fn.modal" 
       crossorigin="anonymous" 
       integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"> 
     </script> 
     <script src="~/js/site.min.js" asp-append-version="true"></script> 


    </environment> 

    @RenderSection("Scripts", required: false) 
    </body> 
</html> 

J'ai eu quelques composants de vue (LoginStatus et MenuItems) mais les transportèrent à essayer d'obtenir ce travail.

Sortie de course:

Microsoft.AspNetCore.Mvc.Razor.Compilation.CompilationFailedException: One or more compilation failures occurred: 
(0,0): Error RZ3007: Targeted tag name cannot be null or whitespace. 
    at Microsoft.AspNetCore.Mvc.Razor.Internal.RazorViewCompiler.CompileAndEmit(String relativePath) 
    at Microsoft.AspNetCore.Mvc.Razor.Internal.RazorViewCompiler.CreateCacheEntry(String normalizedPath) 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() 
    at Microsoft.AspNetCore.Mvc.Razor.Internal.DefaultRazorPageFactoryProvider.CreateFactory(String relativePath) 
    at Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.CreateCacheResult(HashSet`1 expirationTokens, String relativePath, Boolean isMainPage) 
    at Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.OnCacheMiss(ViewLocationExpanderContext expanderContext, ViewLocationCacheKey cacheKey) 
    at Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.LocatePageFromViewLocations(ActionContext actionContext, String pageName, Boolean isMainPage) 
    at Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.FindView(ActionContext context, String viewName, Boolean isMainPage) 
    at Microsoft.AspNetCore.Mvc.ViewEngines.CompositeViewEngine.FindView(ActionContext context, String viewName, Boolean isMainPage) 
    at Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.ViewResultExecutor.FindView(ActionContext actionContext, ViewResult viewResult) 
    at Microsoft.AspNetCore.Mvc.ViewResult.<ExecuteResultAsync>d__26.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeResultAsync>d__19.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeNextResultFilterAsync>d__24.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 
    at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResultExecutedContext context) 
    at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) 
    at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeNextResourceFilter>d__22.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 
    at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context) 
    at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) 
    at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeFilterPipelineAsync>d__17.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeAsync>d__15.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at Microsoft.AspNetCore.Session.SessionMiddleware.<Invoke>d__9.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 
    at Microsoft.AspNetCore.Session.SessionMiddleware.<Invoke>d__9.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.<Invoke>d__6.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.<Invoke>d__7.MoveNext() 

.csproj

<Project Sdk="Microsoft.NET.Sdk.Web"> 

     <PropertyGroup> 
     <TargetFramework>netcoreapp2.0</TargetFramework> 
     <MvcRazorCompileOnPublish>true</MvcRazorCompileOnPublish> 
     <MvcCompileViews>true</MvcCompileViews> 
     <PreserveCompilationContext>true</PreserveCompilationContext> 
     <AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback> 
     <StartupObject>GLCoderConfiguration.Program</StartupObject> 
     </PropertyGroup> 

     <ItemGroup> 
     <PackageReference Include="FluentValidation" Version="7.1.1" /> 
     <PackageReference Include="Microsoft.AspNetCore" Version="2.0.0" /> 
     <PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="2.0.0" /> 
     <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="2.0.0" /> 
     <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.0" /> 
     <PackageReference Include="Microsoft.AspNetCore.Mvc.DataAnnotations" Version="2.0.0" /> 
     <PackageReference Include="Microsoft.AspNetCore.Mvc.Razor" Version="2.0.0" /> 
     <PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.ViewCompilation" Version="2.0.0" PrivateAssets="All" /> 
     <PackageReference Include="Microsoft.AspNetCore.Mvc.TagHelpers" Version="2.0.0" /> 
     <PackageReference Include="Microsoft.AspNetCore.Mvc.ViewFeatures" Version="2.0.0" /> 
     <PackageReference Include="Microsoft.AspNetCore.Razor.Runtime" Version="2.0.0" /> 
     <PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="2.0.0" /> 
     <PackageReference Include="Microsoft.AspNetCore.Session" Version="2.0.0" /> 
     <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.0.0" /> 
     <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.0.0" /> 
     <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.0.0" /> 
     <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.0" /> 
     <PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="2.0.0" /> 
     <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.0.0" /> 
     <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.0.0" /> 
     <PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.0.0" /> 
     <PackageReference Include="Microsoft.NETCore.Platforms" Version="2.0.0" /> 
     <PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="2.0.0" /> 
     <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.0" /> 
     <PackageReference Include="NETStandard.Library" Version="2.0.0" /> 
     <PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.4.0" /> 
     </ItemGroup> 

     <ItemGroup> 
    <ItemGroup> 
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" /> 
    <DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="2.0.0" /> 
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" /> 
    </ItemGroup> 
     <ItemGroup> 
     <ProjectReference Include="..\..\SCMEnumerations\SCMEnumerations.csproj" /> 
     <ProjectReference Include="..\..\TMainModel\TMainModel.csproj" /> 
     <ProjectReference Include="..\..\ViewHelperFunctions\ViewExtensions.csproj" /> 
     </ItemGroup> 

    </Project> 

Répondre

0

Essayez de remplacer environment names avec environment include comme.

<environment include="Staging,Production"> 
    <strong>HostingEnvironment.EnvironmentName is Staging or Production</strong> 
</environment> 

Selon documentation:

La propriété include (dans ASP.NET Core 2.0) présente un comportement similaire de l'attribut names dans ASP.NET de base 1.0.

MISE À JOUR: a essayé de migrer certains de mes projets me (1.1 à 2.0) en utilisant des paquets comme en vous .csproj afin de vous reproduire l'erreur, mais malheureusement pas de chance. Pas sûr, mais peut-être cela causé par la précompilation.

J'ai eu CompilationFailedException parfois mais c'était comme CS0246 et montre des lignes qui ont causé le problème. Mais votre RZ3007 (0,0) ressemble à Razor lui-même en quelque sorte cassé. Vous devriez probablement ouvrir un nouveau numéro sur Github.
Pas sûr si aide, mais aussi essayer d'installer Microsoft.AspNetCore.Razor.Language paquet NuGet, car il semble être nécessaire si vous read this discussion sur les changements Razor.

Essayez également de mettre à jour Visual Studio 2017 vers la version 15.3 si vous ne l'utilisez pas maintenant. Aussi, assurez-vous que le SDK est mis à jour vers la version 2.0

+0

Je l'ai essayé. Pas de dé. Basé sur les docs, je crois que l'attribut names est toujours valide. – dmcquay

+0

@dmcquay Je vois, étrange. Alors s'il vous plaît mettez à jour votre question avec le contenu de votre fichier '* .csproj'. – user2771704

+0

@dmcquay Veuillez vérifier la réponse mise à jour. – user2771704

0

J'ai fini par passer par les étapes détaillées à partir de Microsoft. J'ai ensuite désinstallé complètement Visual Studio et réinstallé. Ensuite, j'ai créé un nouveau projet Web, l'a défini sur la cible 2.0, puis copié les fichiers à partir de la solution non fonctionnelle et les choses ont commencé à fonctionner automatiquement. Je dois toujours m'assurer que l'authentification est correctement configurée mais que les choses commencent à se mettre en ligne.

+0

Salut @dmcquay, j'ai aussi eu ce problème, et j'ai également dû recréer mon projet à partir de zéro pour résoudre le problème, ce que nous ne devrions pas avoir à faire ... J'ai récemment trouvé le problème, sans raison valable pour l'avoir fait ... en regardant à travers mon repo git et en comparant les changements entre la dernière construction réussie! Avez-vous déjà appris des informations supplémentaires sur cette erreur? J'ai passé beaucoup trop de temps avec ce genre d'erreurs avec mon environnement standard de dot net core dev. –

0

Retrait de la ligne ci-dessous de *.csproj il fixe pour moi

<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.ViewCompilation" Version="2.0.0" PrivateAssets="All" />

je l'avais ajouté dans après avoir lu la Vérifiez votre section de réglage Compilation Voir Razor dans le upgrade documents.Il s'avère que ce n'était pas une bonne idée de l'ajouter!