如果未识别引用,则使用 Microsoft.NET.Sdk.Razor 时发布失败,但构建有效

Publish failed when using Microsoft.NET.Sdk.Razor if reference was not recognized, but build works

问题

我已将我的解决方案从 asp.net 核心 2.0 网络应用程序升级到 2.1,并且在我的 class 库之一中,我正在使用“Microsoft.NET.Sdk.Razor”SDK。

解决方案项目:

日志文件显示:

System.AggregateException: One or more errors occurred. ---> System.Exception: Build failed. Check the Output window for more details. --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at Microsoft.VisualStudio.Web.Publish.PublishService.VsWebProjectPublish.<>c__DisplayClass41_0.b__2() at System.Threading.Tasks.Task`1.InnerInvoke() at System.Threading.Tasks.Task.Execute() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.VisualStudio.ApplicationCapabilities.Publish.ViewModel.ProfileSelectorViewModel.d__116.MoveNext() ---> (Inner Exception #0) System.Exception: Build failed. Check the Output window for more details.<---

===================

并且在输出中 window 是

Connecting to C:\Projects\tacs\MyProject\MyProject.Web\bin\Release\netcoreapp2.1\publish\...
MyProject.Web -> C:\Projects\tacs\MyProject\MyProject.Web\bin\Release\netcoreapp2.1\MyProject.Web.dll
C:\Program Files (x86)\Microsoft Visual Studio17\Enterprise\MSBuild.0\Bin\Roslyn\csc.exe /noconfig /unsafe- /checked- /nowarn:1701,1702,1701,1702,2008 /nostdlib+ /errorreport:prompt /warn:4 /define:TRACE;RELEASE;NETCOREAPP;NETCOREAPP2_1 /errorendlocation /preferreduilang:en-US /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.antiforgery.1.0\lib\netstandard2.0\Microsoft.AspNetCore.Antiforgery.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.authentication.abstractions.1.0\lib\netstandard2.0\Microsoft.AspNetCore.Authentication.Abstractions.dll" / /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.mvc.razor.1.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.mvc.razor.extensions.1.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.Extensions.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.mvc.razorpages.1.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.RazorPages.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.mvc.taghelpers.1.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.TagHelpers.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.mvc.viewfeatures.1.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.ViewFeatures.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.razor.1.0\lib\netstandard2.0\Microsoft.AspNetCore.Razor.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.razor.language.1.0\lib\netstandard2.0\Microsoft.AspNetCore.Razor.Language.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.razor.runtime.1.0\lib\netstandard2.0\Microsoft.AspNetCore.Razor.Runtime.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.responsecaching.abstractions.1.0\lib\netstandard2.0\Microsoft.AspNetCore.ResponseCaching.Abstractions.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.routing.abstractions.1.0\lib\netstandard2.0\Microsoft.AspNetCore.Routing.Abstractions.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.routing.1.0\lib\netstandard2.0\Microsoft.AspNetCore.Routing.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.webutilities.1.0\lib\netstandard2.0\Microsoft.AspNetCore.WebUtilities.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.codeanalysis.csharp.8.0\lib\netstandard1.3\Microsoft.CodeAnalysis.CSharp.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.codeanalysis.common.8.0\lib\netstandard1.3\Microsoft.CodeAnalysis.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.codeanalysis.razor.1.0\lib\netstandard2.0\Microsoft.CodeAnalysis.Razor.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\Microsoft.CSharp.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.entityframeworkcore.abstractions.1.0\lib\netstandard2.0\Microsoft.EntityFrameworkCore.Abstractions.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.entityframeworkcore.1.0\lib\netstandard2.0\Microsoft.EntityFrameworkCore.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.entityframeworkcore.relational.1.0\lib\netstandard2.0\Microsoft.EntityFrameworkCore.Relational.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.entityframeworkcore.sqlserver.1.0\lib\netstandard2.0\Microsoft.EntityFrameworkCore.SqlServer.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.extensions.caching.abstractions.1.0\lib\netstandard2.0\Microsoft.Extensions.Caching.Abstractions.dll"  /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.win32.registry.5.0\ref\netstandard2.0\Microsoft.Win32.Registry.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\mscorlib.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\netstandard.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\newtonsoft.json.bson.0.1\lib\netstandard1.3\Newtonsoft.Json.Bson.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\newtonsoft.json.0.2\lib\netstandard2.0\Newtonsoft.Json.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\remotion.linq.2.0\lib\netstandard1.0\Remotion.Linq.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.AppContext.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Buffers.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Collections.Concurrent.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Collections.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Collections.Immutable.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Collections.NonGeneric.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Collections.Specialized.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.ComponentModel.Annotations.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.ComponentModel.DataAnnotations.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.ComponentModel.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.ComponentModel.EventBasedAsync.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.ComponentModel.Primitives.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.ComponentModel.TypeConverter.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Configuration.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Console.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Core.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Data.Common.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Data.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\system.data.sqlclient.5.0\ref\netcoreapp2.1\System.Data.SqlClient.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Diagnostics.Contracts.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Diagnostics.Debug.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Diagnostics.DiagnosticSource.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Diagnostics.FileVersionInfo.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Diagnostics.Process.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Diagnostics.StackTrace.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Diagnostics.TextWriterTraceListener.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Diagnostics.Tools.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Diagnostics.TraceSource.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Diagnostics.Tracing.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Drawing.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Drawing.Primitives.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Dynamic.Runtime.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Globalization.Calendars.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Globalization.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Globalization.Extensions.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\system.interactive.async.1.1\lib\netstandard1.3\System.Interactive.Async.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.IO.Compression.Brotli.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.IO.Compression.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.IO.Compression.FileSystem.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.IO.Compression.ZipFile.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.IO.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.IO.FileSystem.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.IO.FileSystem.DriveInfo.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.IO.FileSystem.Primitives.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.IO.FileSystem.Watcher.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.IO.IsolatedStorage.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.IO.MemoryMappedFiles.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.IO.Pipes.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.IO.UnmanagedMemoryStream.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Linq.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Linq.Expressions.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Linq.Parallel.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Linq.Queryable.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Memory.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Net.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Net.Http.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Net.HttpListener.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Net.Mail.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Net.NameResolution.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Net.NetworkInformation.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Net.Ping.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Net.Primitives.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Net.Requests.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Net.Security.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Net.ServicePoint.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Net.Sockets.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Net.WebClient.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Net.WebHeaderCollection.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Net.WebProxy.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Net.WebSockets.Client.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Net.WebSockets.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Numerics.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Numerics.Vectors.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.ObjectModel.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Reflection.DispatchProxy.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Reflection.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Reflection.Emit.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Reflection.Emit.ILGeneration.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Reflection.Emit.Lightweight.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Reflection.Extensions.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Reflection.Metadata.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Reflection.Primitives.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Reflection.TypeExtensions.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Resources.Reader.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Resources.ResourceManager.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Resources.Writer.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\system.runtime.compilerservices.unsafe.5.0\ref\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Runtime.CompilerServices.VisualC.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Runtime.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Runtime.Extensions.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Runtime.Handles.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Runtime.InteropServices.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Runtime.InteropServices.RuntimeInformation.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Runtime.InteropServices.WindowsRuntime.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Runtime.Loader.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Runtime.Numerics.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Runtime.Serialization.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Runtime.Serialization.Formatters.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Runtime.Serialization.Json.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Runtime.Serialization.Primitives.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Runtime.Serialization.Xml.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\system.security.accesscontrol.5.0\ref\netstandard2.0\System.Security.AccessControl.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Security.Claims.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Security.Cryptography.Algorithms.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Security.Cryptography.Csp.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Security.Cryptography.Encoding.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Security.Cryptography.Primitives.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Security.Cryptography.X509Certificates.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\system.security.cryptography.xml.5.0\ref\netstandard2.0\System.Security.Cryptography.Xml.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Security.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\system.security.permissions.5.0\ref\netstandard2.0\System.Security.Permissions.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Security.Principal.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\system.security.principal.windows.5.0\ref\netstandard2.0\System.Security.Principal.Windows.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Security.SecureString.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.ServiceModel.Web.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.ServiceProcess.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Text.Encoding.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Text.Encoding.Extensions.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\system.text.encodings.web.5.0\lib\netstandard2.0\System.Text.Encodings.Web.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Text.RegularExpressions.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Threading.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Threading.Overlapped.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Threading.Tasks.Dataflow.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Threading.Tasks.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Threading.Tasks.Extensions.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Threading.Tasks.Parallel.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Threading.Thread.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Threading.ThreadPool.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Threading.Timer.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Transactions.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Transactions.Local.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.ValueTuple.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Web.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Web.HttpUtility.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Windows.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Xml.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Xml.Linq.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Xml.ReaderWriter.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Xml.Serialization.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Xml.XDocument.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Xml.XmlDocument.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Xml.XmlSerializer.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Xml.XPath.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\System.Xml.XPath.XDocument.dll" /reference:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app.1.0\ref\netcoreapp2.1\WindowsBase.dll" /debug- /debug:portable /filealign:512 /optimize+ /out:obj\Release\netcoreapp2.1\MyProject.Mail.dll /ruleset:"C:\Program Files (x86)\Microsoft Visual Studio17\Enterprise\Team Tools\Static Analysis Tools\Rule Sets\MinimumRecommendedRules.ruleset" /target:library /warnaserror- /utf8output /deterministic+ /analyzer:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.codeanalysis.analyzers.1.0\analyzers\dotnet\cs\Microsoft.CodeAnalysis.Analyzers.dll" /analyzer:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.codeanalysis.analyzers.1.0\analyzers\dotnet\cs\Microsoft.CodeAnalysis.CSharp.Analyzers.dll" /analyzer:"C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.entityframeworkcore.analyzers.1.0\analyzers\dotnet\cs\Microsoft.EntityFrameworkCore.Analyzers.dll" EmailDefaults.cs EmailOptions.cs MailSender.cs NotificationService.cs RazorViewToStringRenderer.cs "C:\Users\daniel.turan\AppData\Local\Temp\.NETCoreApp,Version=v2.1.AssemblyAttributes.cs" obj\Release\netcoreapp2.1\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs obj\Release\netcoreapp2.1\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs obj\Release\netcoreapp2.1\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs obj\Release\netcoreapp2.1\MyProject.Mail.RazorAssemblyInfo.cs obj\Release\netcoreapp2.1\MyProject.Mail.AssemblyInfo.cs /warnaserror+:NU1605
NotificationService.cs(15,12): Error CS0234: The type or namespace name 'DataAccess' does not exist in the namespace 'MyProject' (are you missing an assembly reference?)
NotificationService.cs(16,12): Error CS0234: The type or namespace name 'DataAccess' does not exist in the namespace 'MyProject' (are you missing an assembly reference?)
...

这是一个错误。即将推出的 SDK 版本 2.1.1 中应该会提供修复程序。您现在可以做 3 件事:

  1. 您可以安装 SDK 2.1.301 (x64 Installer, x86 Installer, Version info)
  2. 或者您可以自己为当前的 2.1.300 SDK 进行修复,它是 C:\Program Files\dotnet\sdk.1.[=34= 中的一行代码].NET.Sdk.Razor\build\netstandard2.0\Sdk.Razor.CurrentVersion.targets 并更改第 460 行:

    DependsOnTargets="RazorCompile"
    

    DependsOnTargets="ResolveRazorGenerateInputs"
    
  3. 或者继续使用dotnet publish

对于我的情况,我安装了 Microsoft.NET.Sdk.Razor 2.2.0

打开"Package Manager Console" 运行 关注查询....

Install-Package Microsoft.NET.Sdk.Razor -Version 2.2.0

Razor 是一种标记语法,用于向网页添加服务器端逻辑。此软件包包含对 Razor 的 MSBuild 支持。