2014-03-31 27 views
2

我使用Nancy Asp.Net Web應用程序模板創建了使用Visual Studio 2013創建的非常簡單的項目。在Linux環境下使用xbuild構建.NET項目

在我的開發機器中,它是通過Visual Studio 2013成功構建的。

但是,當我嘗試使用xbuild在Linux Mono環境中構建相同的源代碼時,它失敗了。

這裏是輸出:

[email protected]:/home/hitly/hitly/src/Hitly.Service# xbuild 
XBuild Engine Version 12.0 
Mono, Version 3.2.8.0 
Copyright (C) 2005-2013 Various Mono authors 

Build started 3/31/2014 2:11:49 PM. 
__________________________________________________ 
Project "/home/hitly/hitly/src/Hitly.Service/Hitly.Service.csproj" (default target(s)): 
     Target RestorePackages: 
       Executing: mono --runtime=v4.0.30319 ../.nuget/NuGet.exe install "" -source "" -RequireConsent -solutionDir "../" 
       The specified path is not of a legal form (empty). /home/hitly/hitly/src/.nuget/NuGet.targets: error : Command 'mono --runtime=v4.0.30319 ../.nuget/NuGet.exe install "" -source "" -RequireConsent -solutionDir "../"' exited with code: 1. 
     Task "Exec" execution -- FAILED 
     Done building target "RestorePackages" in project "/home/hitly/hitly/src/Hitly.Service/Hitly.Service.csproj".-- FAILED 
Done building project 
"/home/hitly/hitly/src/Hitly.Service/Hitly.Service.csproj".-- FAILED 

Build FAILED. Errors: 

/home/hitly/hitly/src/Hitly.Service/Hitly.Service.csproj (default targets) -> /home/hitly/hitly/src/.nuget/NuGet.targets 
(RestorePackages target) -> 

     /home/hitly/hitly/src/.nuget/NuGet.targets: error : Command 'mono --runtime=v4.0.30319 ../.nuget/NuGet.exe install "" -source "" -RequireConsent -solutionDir "../"' exited with code: 1. 

     0 Warning(s) 
     1 Error(s) 

Time Elapsed 00:00:00.7254640 

我沒有理解錯誤的原因。

如何在Linux上構建這些源代碼?

回答

5

固定!

我只是簡單地添加PackagesConfig元素.nuget/NuGet.targets

<PropertyGroup Condition=" '$(OS)' != 'Windows_NT'"> 
    <!-- We need to launch nuget.exe with the mono command if we're not on windows --> 
    <NuGetToolsPath>$(SolutionDir).nuget</NuGetToolsPath> 
    ++++<PackagesConfig>packages.config</PackagesConfig> 
</PropertyGroup> 
+0

我沒有'NuGet.targets'文件中'〜/.nuget'文件夾,只有'NuGet.exe' .. –

+0

如何使用默認設置創建一個? –

2

NuGet.targets是NuGet包一鍵還原文件,但它的版本不能很好的NuGet人管理。

您遇到的問題僅表示您使用的版本不是單聲道友好的。您的編輯可能有效,但我建議您留意NuGet Git存儲庫以獲取最新內容,例如http://nuget.codeplex.com/SourceControl/latest#src/Build/NuGet.targets

Hope NuGet傢伙可以在Mono上做更多的測試,因爲這可以防止長期的類似問題。

(請忘了這個答案。最新的NuGet控制檯可以在運行最新的單聲道和恢復機制也發生了變化,以擺脫這種目標的文件。)

+1

我需要在Linux中運行Nuget,NuGet Git存儲庫頁面(在GitHub)中的文檔沒有描述如何在Linux下構建它,我錯過了什麼?謝謝。 –

+1

@ W.M。您現在應該只使用Mono上的NuGet.exe,並且此答案不再有效。 –