当我尝试编译1.1应用程序时,我收到了编译错误。我正在将此应用程序从Rc1转换为1.1,对项目文件进行必要的更改,包没有错误地恢复,但是在编译它时会出现此错误。
该解决方案还有其他Web项目,引用相同的公共类库,所有编译都没有任何错误......
在vs2015(在win10上),我安装了这些软件包:
DotNetCore.1.0.1-VS2015Tools.Preview2.0.3.exe
DotNetCore.1.0.1-SDK.1.0.0.Preview2-003131-x64.exe程序
------ Rebuild All started: Project: MyCommon.Model, Configuration: Debug Any CPU ------
C:\Program Files\dotnet\dotnet.exe build "c:\work\proj\Trunk\Gsb\MyCommon.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 Files\dotnet\dotnet.exe build "c:\work\proj\Trunk\Gsb\MyCommon.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 Files\dotnet\dotnet.exe build "c:\work\proj\Trunk\Gsb\Gsbr.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 Files\dotnet\dotnet.exe compile-csc @c:\work\proj\Trunk\Gsb\Gsbr.Web\obj\Debug\netcoreapp1.1\dotnet-compile.rsp returned Exit Code 1
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets(262,5): error : c:\work\proj\Trunk\Gsb\Gsbr.Web\error 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
未显示任何错误。
答案 0 :(得分:2)
花了好几个小时后,我终于发现问题是由.cshtml文件名引起的" - "在里面 !!!重命名该文件后,编译器开始工作,我终于可以编译该项目了。文件名中的连字符导致编译器失败。文件名是由visual studio在复制另一个文件时创建的(filename - copy.cshtml) 希望这有助于其他人。