我正在使用Visual Studio Online進行回購和構建。這是我的TFS層次結構。Visual Studio Online構建失敗依賴項目NuGet參考
<ClassLibraries>
│
├───<Solution 1>
│ └───Build.Proj
│ └───.NuGet
│ └───NuGet.exe
│ └───NuGet.Config
│ └───NuGet.Targets
│ └───<Project 1> // Common Code
│ └───Project1.csproj
│ └───<Project 2> // Common Code Unit Test
│ └───Project2.csproj
│
├───<Solution 2>
│ └───Build.Proj
│ └───.NuGet
│ └───NuGet.exe
│ └───NuGet.Config
│ └───NuGet.Targets
│ └───<Project 3>
│ └───Project1.csproj
│ └───<Project 4>
│ └───Project2.csproj
我有一個解決方案1的構建定義成功構建,根據需要恢復NuGet包沒有問題。
解決方案2.sln文件包含解決方案1中的項目1作爲依賴項,因爲項目3和項目4都對它有代碼依賴性(解決方案1是我的通用代碼解決方案,幾乎包含在所有內容中)。
解決方案2的構建定義失敗,因爲它無法找到項目1的NuGet依賴關係。我猜測Build.Proj中的RestorePackages目標忽略了依賴項目。
<Target Name="RestorePackages">
<Exec Command="$(MSBuildThisFileDirectory).NuGet\NuGet.exe restore %(Solution.Identity)" />
</Target>
我不明白爲什麼。如果我在解決方案2上本地執行「msbuild build.proj」,那麼它會成功清理並構建所有項目。