简体   繁体   English

使用xbuild构建C#解决方案时出错(单声道)

[英]Error building C# Solution using xbuild (mono)

I've searched the depths of the internet and I cannot find an answer or workaround for this problem. 我已经搜索了互联网的深度,但找不到此问题的答案或解决方法。 I have no idea either what is causing it. 我也不知道是什么原因造成的。

I keep getting the error in Xamarin Studio: 我在Xamarin Studio中不断收到错误消息:

Error: Error building target GetReferenceAssemblyPaths: UNC paths should be of the form     \\server\share.

Can someone explain this to me? 谁可以给我解释一下这个?

Here's a link to one of the project files: http://pastebin.com/qZ5uGL9S 这是项目文件之一的链接: http : //pastebin.com/qZ5uGL9S

If you inspect your project file you have a couple of extra backslashes in some of your FXCopy rule paths ie 如果您检查项目文件,则在某些FXCopy规则路径中会有两个额外的反斜线,即

<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools**\\**Rule Sets</CodeAnalysisRuleSetDirectories>
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop**\\**Rules</CodeAnalysisRuleDirectories>
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools**\\**Rule Sets</CodeAnalysisRuleSetDirectories>
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop**\\**Rules</CodeAnalysisRuleDirectories>

The compiler is probably picking these up as UNC paths, replace them with a single backslash and it should compile ok. 编译器可能会选择这些作为UNC路径,用一个反斜杠替换它们,并且应该可以正常编译。

取消选中 use MSBuild并对其进行了修复。

When I created my project in Microsoft Visual Studio 2012, I selected TargetFrameworkVersion 3.5. 在Microsoft Visual Studio 2012中创建项目时,选择了TargetFrameworkVersion 3.5。 Visual Studio 2012 creates project files with ToolsVersion="4.0" . Visual Studio 2012使用ToolsVersion =“ 4.0”创建项目文件。 Apparently the Mono installation (mine was 3.2.3) doesn't digest the 4.0 toolset very well. 显然,Mono安装(我的版本是3.2.3)不能很好地理解4.0工具集。 So I opened my csproj file in Notepad and changed it to ToolsVersion="3.5" . 因此,我在记事本中打开了csproj文件,并将其更改为ToolsVersion =“ 3.5” It fixed the problem. 它解决了问题。

NB: TargetFrameworkVersion and ToolsVersion are two different things. 注意:TargetFrameworkVersion和ToolsVersion是两个不同的东西。 ToolsVersion specifies the version of MSBuild tools to use when building your project whereas TargetFrameworkVersion is the version of .NET Framework to target. ToolsVersion指定在构建项目时使用的MSBuild工具的版本,而TargetFrameworkVersion是要定位的.NET Framework的版本。

Slightly unrelated, but I received a similar error immediately when building a coworker's old Visual Studio project: 稍微无关,但是在构建同事的旧Visual Studio项目时,我立即收到了类似的错误:

Error: Failed to write to log file "\\projName.log". The UNC path should be of the form \\server\share.

I fixed it by changing the Project Configuration Properties Build Log File field. 我通过更改“项目配置属性构建日志文件”字段来修复它。 It had incorrect variables that were evaluating to blank: 它有不正确的变量,被评估为空白:

$(IntDir)\$(MSBuildProjectName).log

Fixing this allowed the build to run flawlessly. 修复此问题可使构建完美运行。 Maybe this will help someone, or I can open a new question and answer it. 也许这会对某人有所帮助,或者我可以打开一个新问题并回答。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM