C# DotNetCore 1.1应用程序编译错误:CS2007:无法识别的选项:'-' ;网络 ;C:\…Microsoft.DotNet.Com
当我试图编译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.exeC# DotNetCore 1.1应用程序编译错误:CS2007:无法识别的选项:'-' ;网络 ;C:\…Microsoft.DotNet.Com,c#,visual-studio-2015,.net-core,C#,Visual Studio 2015,.net Core,当我试图编译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
不显示任何错误
我做错了什么?是什么导致了这个错误?在花了几个小时的时间后,我终于发现这个问题是由一个带有“-”的.cshtml文件名引起的!!!重命名该文件后,编译器开始工作,我终于可以编译该项目了。文件名中的连字符导致编译器失败。该文件名是由visual studio在复制另一个文件时创建的(filename-copy.cshtml)
希望这对其他人有所帮助。如果从命令行运行
dotnet build
,是否会出现相同的错误?是的,我在运行dotnet build>dotnet Microsoft.NET Core共享框架主机版本1.1.0 build:928f77c4bc3f49d892459992fb6e1d5542cb5e86I时遇到了相同的问题,在dotnet Core可执行文件中嵌入.sql脚本-是由文件名包含空格和“-”字符的组合引起的-“data-01.sql”很好,“data-01.sql”是个问题!谢谢你给我指明了正确的方向!