我尝试编译1.1应用程序时会遇到汇编错误。我正在将此应用程序从RC1转换为1.1,对项目文件进行了必要的更改,毫无疑问的软件包恢复了,但是在编译时会出现此错误。
也有其他Web项目,引用了相同的普通类库,所有这些都没有任何错误...
在VS2015(在Win10上),我安装了这些软件包:
dotnetcore.1.0.1-vs2015tools.preview2.0.3.3.exe
dotnetcore.1.0.1-sdk.1.0.0.0.preview2-003131-x64.exe
------ Rebuild All started: Project: MyCommon.Model, Configuration: Debug Any CPU ------
C:Program Filesdotnetdotnet.exe build "c:workprojTrunkGsbMyCommon.Model" --configuration Debug --no-dependencies --no-incremental
Project MyCommon.Model (.NETStandard,Version=v1.6) will be compiled because project is not safe for incremental compilation. Use --build-profile flag for more information.
Compiling MyCommon.Model for .NETStandard,Version=v1.6
Compilation succeeded.
0 Warning(s)
0 Error(s)
Time elapsed 00:00:02.1608612
(The compilation time can be improved. Run "dotnet build --build-profile" for more information)
------ Rebuild All started: Project: MyCommon.Utilities, Configuration: Debug Any CPU ------
C:Program Filesdotnetdotnet.exe build "c:workprojTrunkGsbMyCommon.Utilities" --configuration Debug --no-dependencies --no-incremental
Project MyCommon.Utilities (.NETStandard,Version=v1.6) will be compiled because project is not safe for incremental compilation. Use --build-profile flag for more information.
Compiling MyCommon.Utilities for .NETStandard,Version=v1.6
Compilation succeeded.
0 Warning(s)
0 Error(s)
Time elapsed 00:00:02.0359443
(The compilation time can be improved. Run "dotnet build --build-profile" for more information)
------ Rebuild All started: Project: Gsbr.Web, Configuration: Debug Any CPU ------
C:Program Filesdotnetdotnet.exe build "c:workprojTrunkGsbGsbr.Web" --configuration Debug --no-dependencies --no-incremental
Project Gsbr.Web (.NETCoreApp,Version=v1.1) will be compiled because project is not safe for incremental compilation. Use --build-profile flag for more information.
Compiling Gsbr.Web for .NETCoreApp,Version=v1.1
C:Program Filesdotnetdotnet.exe compile-csc @c:workprojTrunkGsbGsbr.WebobjDebugnetcoreapp1.1dotnet-compile.rsp returned Exit Code 1
C:Program Files (x86)MSBuildMicrosoftVisualStudiov14.0DotNetMicrosoft.DotNet.Common.Targets(262,5): error : c:workprojTrunkGsbGsbr.Weberror CS2007: Unrecognized option: '-'
Compilation failed.
0 Warning(s)
1 Error(s)
Time elapsed 00:00:33.7698291
========== Rebuild All: 2 succeeded, 1 failed, 0 skipped ==========
project.json就是这样:
{
"version": "1.0.0-*",
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.1.0",
"type": "platform"
},
"Microsoft.AspNetCore.Diagnostics": "1.1.0",
"Microsoft.AspNetCore.Mvc": "1.1.0",
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.1.0-preview4-final",
"type": "build"
},
"Microsoft.AspNetCore.Routing": "1.1.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
"Microsoft.AspNetCore.StaticFiles": "1.1.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0",
"Microsoft.Extensions.Configuration.Json": "1.1.0",
"Microsoft.Extensions.Logging": "1.1.0",
"Microsoft.Extensions.Logging.Console": "1.1.0",
"Microsoft.Extensions.Logging.Debug": "1.1.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0",
"Microsoft.AspNetCore.Authorization": "1.1.0",
"Microsoft.AspNetCore.Authentication.Cookies": "1.1.0" ,
"Microsoft.Extensions.Configuration.FileExtensions": "1.1.0",
"Microsoft.Extensions.DependencyInjection": "1.1.0",
"MyCommon.Model": "1.0.0-*",
"MyCommon.Utilities": "1.0.0-*",
"Microsoft.AspNetCore.Http": "1.1.0",
"Newtonsoft.Json": "9.0.1",
"Telerik.UI.for.AspNet.Core": "2017.1.118",
"Microsoft.AspNetCore.Session": "1.1.0",
"Microsoft.AspNetCore.Mvc.TagHelpers": "1.1.0",
"System.Net.Http": "4.3.0"
},
"tools": {
"BundlerMinifier.Core": "2.0.238",
"Microsoft.AspNetCore.Razor.Tools": "1.1.0-preview4-final",
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0-preview4-final"
},
"frameworks": {
"netcoreapp1.1": {
"imports": [
"dotnet5.6",
"portable-net45+win8"
]
}
},
"buildOptions": {
"emitEntryPoint": true,
"warningsAsErrors": true,
"preserveCompilationContext": true,
"embed": "Views/**",
"compile": {
"exclude": [ "wwwroot", "node_modules" ]
}
},
"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
},
"publishOptions": {
"include": [
"wwwroot",
"**/*.cshtml",
"appsettings.json",
"Config/*.json",
"web.config"
]
},
"scripts": {
"prepublish": [ "bower install", "dotnet bundle" ],
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}
project.json
或Startup.cs
不显示任何错误。
我在做什么错?什么可能导致错误?
花了几个小时后,我终于发现问题是由带有" - "的.cshtml文件名引起的!!!重命名该文件后,编译器开始工作,我最终可以编译该项目。文件名中的连字符正在导致编译器失败。该文件名是由Visual Studio复制另一个文件时创建的(文件名-Copy.cshtml)希望这对别人有帮助。