2015-03-03 87 views
0

在团队构建编译期间,我需要从.sln文件中排除abc.Test.csproj通过MSBuild参数排除/删除.csproj

我试过使用/ignoreprojectextensions=.Test.csproj,但不适合我的目的。请帮助我完成此操作。

+0

为什么你不想建立这个项目? – 2015-03-04 19:06:12

+0

,因为团队构建我的目标是假设没有单元测试用例构建proj。 – prashanthkr08 2015-03-05 08:10:15

回答

0

您将创建一个新的配置(调试和发布是默认配置),并且在这个新的配置中,您不会构建指定的.csproj。

然后你会建立到该配置。

参见:

Does Msbuild recognise any build configurations other than DEBUG|RELEASE

追加

没有做新的/自定义的配置,这是我能够理性的唯一解决方案。

把下面的一个名为 “MyBuild.proj” 文件,并调用

msbuild.exe MyBuild.proj 

..

<?xml version="1.0" encoding="utf-8"?> 
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="AllTargetsWrapped"> 

    <PropertyGroup> 
     <WorkingDirectory>.</WorkingDirectory> 
    </PropertyGroup> 

    <Target Name="AllTargetsWrapped"> 
     <CallTarget Targets="ShowReservedProperties" /> 
     <CallTarget Targets="BuildOtherProjects" /> 
    </Target> 

    <Target Name="BuildOtherProjects"> 

     <ItemGroup> 
      <ProjectReferencesExcludes Include="$(WorkingDirectory)\UnitTests.csproj" /> 
      <ProjectReferencesExcludes Include="$(WorkingDirectory)\SomeOtherProject.csproj" /> 
     </ItemGroup> 

     <ItemGroup> 
      <ProjectReferences Include="$(WorkingDirectory)\**\*.*proj" Exclude="@(ProjectReferencesExcludes)" /> 
     </ItemGroup> 

     <Message Text="List of projs to be built:"/> 
     <Message Text="@(ProjectReferences->'&quot;%(fullpath)&quot;' , '%0D%0A')"/> 
     <Message Text=" "/> 
     <Message Text=" "/> 

     <MSBuild 
      Projects="@(ProjectReferences)" 
      Targets="Build"> 
      <Output 
       TaskParameter="TargetOutputs" 
       ItemName="AssembliesBuiltByChildProjects" /> 
     </MSBuild> 

    <Message Text=" "/> 
    <Message Text=" "/>   
    <Message Text="List of AssembliesBuiltByChildProjects:"/> 
    <Message Text="@(AssembliesBuiltByChildProjects->'&quot;%(fullpath)&quot;' , '%0D%0A')"/> 
    <Message Text=" "/> 
    <Message Text=" "/> 


    </Target> 

    <Target Name="ShowReservedProperties"> 

     <Message Text="MSBuild: $(MSBuild)"/> 
     <Message Text="MSBuildBinPath: $(MSBuildBinPath)"/> 
     <Message Text="MSBuildExtensionsPath: $(MSBuildExtensionsPath)"/> 
     <Message Text="MSBuildExtensionsPath32: $(MSBuildExtensionsPath32)"/> 
     <Message Text="MSBuildExtensionsPath64: $(MSBuildExtensionsPath64)"/> 
     <Message Text="MSBuildLastTaskResult: $(MSBuildLastTaskResult)"/> 
     <Message Text="MSBuildNodeCount: $(MSBuildNodeCount)"/> 
     <Message Text="MSBuildOverrideTasksPath: $(MSBuildOverrideTasksPath)"/> 
     <Message Text="MSBuildProgramFiles32: $(MSBuildProgramFiles32)"/> 
     <Message Text="MSBuildProjectDefaultTargets: $(MSBuildProjectDefaultTargets)"/> 
     <Message Text="MSBuildProjectDirectory: $(MSBuildProjectDirectory)"/> 
     <Message Text="MSBuildProjectDirectoryNoRoot: $(MSBuildProjectDirectoryNoRoot)"/> 
     <Message Text="MSBuildProjectExtension: $(MSBuildProjectExtension)"/> 
     <Message Text="MSBuildProjectFile: $(MSBuildProjectFile)"/> 
     <Message Text="MSBuildProjectFullPath: $(MSBuildProjectFullPath)"/> 
     <Message Text="MSBuildProjectName: $(MSBuildProjectName)"/> 
     <Message Text="MSBuildStartupDirectory: $(MSBuildStartupDirectory)"/> 
     <Message Text="MSBuildThisFile: $(MSBuildThisFile)"/> 
     <Message Text="MSBuildThisFileDirectory: $(MSBuildThisFileDirectory)"/> 
     <Message Text="MSBuildThisFileDirectoryNoRoot: $(MSBuildThisFileDirectoryNoRoot)"/> 
     <Message Text="MSBuildThisFileExtension: $(MSBuildThisFileExtension)"/> 
     <Message Text="MSBuildThisFileFullPath: $(MSBuildThisFileFullPath)"/> 
     <Message Text="MSBuildThisFileName: $(MSBuildThisFileName)"/> 
     <Message Text="MSBuildToolsPath: $(MSBuildToolsPath)"/> 
     <Message Text="MSBuildToolsVersion: $(MSBuildToolsVersion)"/>  

    </Target> 





</Project> 

注意,如果你把在的csproj排除列表中,但另一csproj引用/取决于它,它将被构建(不管你“排除”什么)。

+0

非常感谢您的回复。 我有超过30个解决方案文件与大量的Test.csproj创建一个新的配置将是乏味的。是否有可以跳过构建Test.csproj文件的MSBuild参数。 感谢 普拉香特 – prashanthkr08 2015-03-04 08:05:01

+0

据我所知.... – granadaCoder 2015-03-04 14:10:06

+0

http://stackoverflow.com/questions/9778916/how-to-exclude-project-from-build-in-msbuild – granadaCoder 2015-03-04 14:24:47