Visual studio 多个生成项目的csproj文件设置
我有一个解决方案结构:Visual studio 多个生成项目的csproj文件设置,visual-studio,msbuild,csproj,Visual Studio,Msbuild,Csproj,我有一个解决方案结构: Solution.sln |--WebUI.csproj (has Core.csproj as dependency) |--Core.csproj |--Tests |--UnitTests |--WebUI.UnitTest.csproj (has Core.csproj and WebUI.csproj as dependencies) |--Core.UnitTest.csproj (has Cor
Solution.sln
|--WebUI.csproj (has Core.csproj as dependency)
|--Core.csproj
|--Tests
|--UnitTests
|--WebUI.UnitTest.csproj (has Core.csproj and WebUI.csproj as dependencies)
|--Core.UnitTest.csproj (has Core.csproj as dependency)
我应该向WebUI.csproj添加什么来一起构建WebUI.UnitTest.csproj和Core.UnitTest.csproj?(在我的WebUI\bin文件夹中,我需要这些lib:WebUI.UnitTest.dll和Core.UnitTest.dll)
谢谢 直接方法是添加WebUI.UnitTest项目和Core.UnitTest项目作为WebUI项目的依赖项。但是WebUI.UnitTest项目已经将WebUI.csproj作为依赖项,此方法在解决方案结构中不起作用。如果只想在WebUI\bin文件夹中包含WebUI.UnitTest.dll和Core.UnitTest.dll,可以在WebUI.csproj中添加任务,将这些文件复制到文件夹中:
<Target Name="AfterBuild">
<PropertyGroup>
<SolutionDir>$([System.IO.Path]::GetDirectoryName($(MSBuildProjectDirectory)))</SolutionDir>
</PropertyGroup>
<Exec Command=""$(MSBuildBinPath)\MSBuild.exe" "$(SolutionDir)\WebUI.UnitTest\WebUI.UnitTest.csproj"" />
<Exec Command=""$(MSBuildBinPath)\MSBuild.exe" "$(SolutionDir)\Core.UnitTest\Core.UnitTest.csproj"" />
<PropertyGroup>
<CopyFileOutput>$(SolutionDir)\WebUI.UnitTest\bin\Debug\WebUI.UnitTest.dll;$(SolutionDir)\Core.UnitTest\bin\Debug\Core.UnitTest.dll</CopyFileOutput>
</PropertyGroup>
<Copy
SourceFiles="$(CopyFileOutput)"
DestinationFolder="$(SolutionDir)\WebUI\bin"
/>
$([System.IO.Path]::GetDirectoryName($(MSBuildProjectDirectory)))
$(SolutionDir)\WebUI.UnitTest\bin\Debug\WebUI.UnitTest.dll$(SolutionDir)\Core.UnitTest\bin\Debug\Core.UnitTest.dll
注意:stijn的评论是正确的,您构建了解决方案,WebUI.UnitTest.csproj和Core.UnitTest.csproj应该已经构建好了
我还在WebUI.csproj中添加了WebUI.UnitTest.csproj和Core.UnitTest.csproj的构建步骤,这样您只需要构建WebUI.csproj。如果您构建解决方案,WebUI.UnitTest.csproj和Core.UnitTest.csproj应该已经构建好了。为什么要从WebUI.csproj中构建它们?(如果这是你想要的,我甚至不确定我是否理解这个问题)