我正在使用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”,那么它会成功清理并构建所有项目。