通过MSBuild参数排除/删除.csproj

时间:2015-03-03 13:49:44

标签: visual-studio-2013 msbuild tfsbuild

我需要在团队构建编译期间从abc.Test.csproj文件中排除.sln

我尝试使用/ignoreprojectextensions=.Test.csproj,但不能达到我的目的。请帮我完成这个。

1 个答案:

答案 0 :(得分:0)

您将创建一个新配置(Debug和Release是默认配置),在这个新配置中,您将不会构建指定的.csproj。

然后你将构建到该配置。

请参阅:

Does Msbuild recognise any build configurations other than DEBUG|RELEASE

APPEND

没有进行新的/自定义配置,这是我能解释的唯一解决方案。

将以下内容放在名为" 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引用/取决于它,它将被构建(无论你&#34;排除&#34;)。