TFS2008递归复制文件并不总是有效(编译vs2003)(AfterCompile目标)

时间:2009-03-06 19:07:23

标签: tfs2008

我在TFS2008中没有SP1的自定义脚本中复制文件时遇到一些奇怪的问题,我必须多次运行构建才能复制文件(大多数情况下它是在我获取文件的第二个版本中) ,让我告诉你详情:

ASP站点和VS2003 Web解决方案正在发生这种情况(vs2008解决方案还可以) 在ASP我有一个虚拟2008解决方案,构建编译这个虚拟,我重写AfterCompile并在那里我将所有文件复制到放置位置 在VS 2003中,我还有一个虚拟2008解决方案,构建首先编译虚拟,我重写AfterCompile,使用“Exec”和“Command”编译2003解决方案,然后将文件复制到放置位置。

正如你可以看到两种方法都相似,我对构建本身没有问题,我的问题可以通过两种方式重现(是的,我会检查,更新,检入然后测试构建) :

  1. 创建新版本,配置脚本,第一次运行构建,bin文件夹中的某些DLL不会被复制,第二次运行构建并获取所有文件。

  2. 构建已配置并运行正常,将一些文件添加到项目中(这主要发生在ASP站点上),运行构建,不要获取此新文件,再次运行构建,我得到这个新的文件

  3. 这是我的VS2003 Web解决方案的构建脚本,作为示例

    <PropertyGroup> 
    <TasksPath>D:\BuildTools\</TasksPath> 
        <VS2003Devenv>D:\Archivos de programa\Microsoft Visual Studio .NET 2003\Common7\IDE\devenv.com</VS2003Devenv> 
        <VS2003VirtualFolder>CnbvPifWeb</VS2003VirtualFolder> 
        <VS2003Suba>Cnbv.Pif.Web</VS2003Suba> 
        <VS2003Project>Cnbv.Pif.Web</VS2003Project> 
        <VS2003WebSiteName>Sitio Web predeterminado</VS2003WebSiteName> 
        <VS2003Configuration>Release</VS2003Configuration> 
        <VS2003Branch>Desarrollo</VS2003Branch> 
        <VS2003RelativePath>$(SolutionRoot)\$(VS2003Branch)\$(VS2003Suba)\</VS2003RelativePath> 
        <VS2003SolutionPath>$(VS2003RelativePath)Cnbv.Pif.Web.sln</VS2003SolutionPath> 
        <VS2003LocalFolder>$(VS2003RelativePath)Sources\$(VS2003Project)\</VS2003LocalFolder> 
        <VS2003Output>$(BinariesRoot)\$(VS2003Project)\</VS2003Output> 
        <VS2003CachePath>C:\Documents and Settings\srvfoundation\VSWebCache\230-2555-CPU015\</VS2003CachePath> 
        <VS2003ProjectExtension>vbproj</VS2003ProjectExtension> 
        <VS2003CacheFile>$(VS2003CachePath)$(VS2003VirtualFolder)\_vti_pvt\$(VS2003Project).$(VS2003ProjectExtension).cache</VS2003CacheFile>
    </PropertyGroup> 
    <Import Project="$(TasksPath)Microsoft.Sdc.Common.tasks"/> 
    <UsingTask TaskName="Microsoft.Sdc.Tasks.Web.WebSite.CreateVirtualDirectory" AssemblyFile="Microsoft.Sdc.Tasks.dll" /> 
    <UsingTask TaskName="Microsoft.Sdc.Tasks.Web.WebSite.DeleteVirtualDirectory" AssemblyFile="Microsoft.Sdc.Tasks.dll" /> 
    <ItemGroup> 
        <!--list of ouput files, excluding .DLL outside bin and some other files--> 
            <VS2003OutputFiles 
                Include="$(VS2003LocalFolder)**\*.*" 
                Exclude="$(VS2003LocalFolder)**\*.vb;$(VS2003LocalFolder)**\*.cs;$(VS2003LocalFolder)**\*.resx;$(VS2003LocalFolder)**\*.vspscc;$(VS2003LocalFolder)**\*.csproj;$(VS2003LocalFolder)**\*.vbproj;$(VS2003LocalFolder)**\*.scc;$(VS2003LocalFolder)**\*.webinfo;$(VS2003LocalFolder)**\*.snk;$(VS2003LocalFolder)**\*.dll;$(VS2003LocalFolder)**\*.exe;" />
        <!-- copy dll to bin folder -->
            <VS2003OutputBinFiles 
            Include="$(VS2003LocalFolder)bin\*.dll"/> 
    </ItemGroup> 
    <Target Name="AfterCompile"> 
    <Message Text="Deleting cache file" /> 
        <Microsoft.Build.Tasks.Delete 
            Condition="Exists('$(VS2003CacheFile)')" 
            Files="$(VS2003CacheFile)" /> 
        <Message Text="Creating virtual folder $(VS2003VirtualFolder) in IIS in local path $(VS2003LocalFolder)" /> 
        <Web.WebSite.CreateVirtualDirectory 
            VirtualDirectoryName="$(VS2003VirtualFolder)" 
            Path="$(VS2003LocalFolder)" 
            WebSiteName="$(VS2003WebSiteName)" /> 
        <Message Text="Compiling $(VS2003Project) in $(VS2003Branch)" /> 
        <Exec 
            Command="&quot;$(VS2003Devenv)&quot; &quot;$(VS2003SolutionPath)&quot; /build $(VS2003Configuration) /out &quot;$(VS2003LocalFolder)$(VS2003Project).log&quot; "/> 
        <Message Text="Eliminando la carpeta virtual $(VS2003VirtualFolder) en IIS" /> 
        <Web.WebSite.DeleteVirtualDirectory 
            WebSiteName="$(VS2003WebSiteName)" 
            VirtualDirectoryName="$(VS2003VirtualFolder)" /> 
        <MakeDir Condition="!Exists('$(VS2003Output)')" Directories="$(VS2003Output)" /> 
        <Message Text="Copying output files @(VS2003OutputFiles)" /> 
        <Copy 
            SourceFiles="@(VS2003OutputFiles)" 
            DestinationFiles="@(VS2003OutputFiles->'$(VS2003Output)%(RecursiveDir)%(Filename)%(Extension)')" 
        /> 
        <MakeDir Condition="!Exists('$(VS2003Output)bin\')" Directories="$(VS2003Output)bin\" /> 
        <Message Text="Copying DLL to bin folder @(VS2003OutputBinFiles)" /> 
        <Copy 
            SourceFiles="@(VS2003OutputBinFiles)" 
            DestinationFiles="@(VS2003OutputBinFiles->'$(VS2003Output)bin\%(Filename)%(Extension)')" 
        /> 
        <OnError ExecuteTargets="VS2003Fail" />
    </Target>
        <Target Name="VS2003Fail"> 
    <Message Text="Copying log file $(VS2003RelativePath)$(VS2003Project).log" /> 
        <Copy Condition="Exists('$(VS2003RelativePath)$(VS2003Project).log')" SourceFiles="$(VS2003RelativePath)$(VS2003Project).log" DestinationFolder="$(DropLocation)\$(BuildNumber)" /> 
        <CallTarget ContinueOnError ="true" Targets ="CreateWorkItemWhenPartialSucceed" /> 
    </Target> 
    <Target 
            Name="CreateWorkItemWhenPartialSucceed" 
            Condition=" '$(SkipWorkItemCreation)'!='true' and '$(IsDesktopBuild)'!='true' "> 
            <Message Text="ejecutando work" /> 
            <PropertyGroup> 
                <WorkItemTitle>$(WorkItemTitle) $(BuildNumber)</WorkItemTitle> 
                <BuildLogText>$(BuildlogText) &lt;ahref='file:///$(DropLocation)\$(BuildNumber)\BuildLog.txt'&gt;$(DropLocation)\$(BuildNumber)\BuildLog.txt&lt;/a &gt;.</BuildLogText> 
                <ErrorWarningLogText     Condition="!Exists('$(MSBuildProjectDirectory)\ErrorsWarningsLog.txt')"></ErrorWarningLogText> 
            <ErrorWarningLogText Condition="Exists('$(MSBuildProjectDirectory)\ErrorsWarningsLog.txt')">$(ErrorWarningLogText) &lt;a href='file:///$(DropLocation)\$(BuildNumber)\ErrorsWarningsLog.txt'&gt;$(DropLocation)\$(BuildNumber)\ErrorsWarningsLog.txt&lt;/a &gt;.</ErrorWarningLogText> 
            <WorkItemDescription>$(DescriptionText) %3CBR%2F%3E $(BuildlogText) %3CBR%2F%3E $(ErrorWarningLogText)</WorkItemDescription> 
        </PropertyGroup> 
            <CreateNewWorkItem 
            TeamFoundationServerUrl="$(TeamFoundationServerUrl)" 
      BuildUri="$(BuildUri)" 
      BuildNumber="$(BuildNumber)" 
      Description="$(WorkItemDescription)" 
      TeamProject="$(TeamProject)" 
      Title="$(WorkItemTitle)" 
      WorkItemFieldValues="$(WorkItemFieldValues)" 
      WorkItemType="$(WorkItemType)" 
      ContinueOnError="true" /> 
    </Target> 
    

    当我在日志中看到此消息的输出时

    <Message Text="Copying DLL to bin folder @(VS2003OutputBinFiles)" />
    

    我第一次看到一个文件的名称,第二次打印所有正确的文件,ASP站点也是如此,如果我添加一个文件,我会在第二个版本的输出中看到该文件

    我希望你能帮助我解决这个问题,非常感谢。

    Juan Zamudio

1 个答案:

答案 0 :(得分:0)

这是OsirisJakob

在tfs论坛中的答案

问题是您在根级别定义项目组。这意味着在加载项目文件时会立即对它们进行评估。你想要的是在执行AfterCompile目标时对它们进行评估。

由于您正在运行TFS 2008,因此可以通过将项目组移动到AfterCompile目标(a.k.a.动态项目组)来解决此问题。这将导致在执行AfterCompile目标时评估项目组,并为您提供正确的结果。