簡體   English   中英

在TFS上使用MsBuild構建部署程序包之前,將文件復制到源代碼中

[英]Copying files into the source code before building a deploy package with MsBuild on TFS

我使用TFS作為構建服務器,使用MsBuild來構建解決方案並將其打包到Web部署程序包中。

MSBuild參數: /p:CreatePackageOnPublish=true /p:DeployOnBuild=true /p:DeployTarget=Package

現在,我想構建軟件包之前將幾個文件復制到源文件中,以便在部署到IIS時它們將最終位於App_Data目錄中。 我正在考慮將其作為TFS構建的一部分,並創建了一個InvokeProcess-action,該操作調用xcopy並將文件復制到SourcesDirectory中,但是它們未出現在內置的zip軟件包中。

我應該將文件復制到哪個目錄中,以及在構建過程中的哪個位置? 有更好的方法嗎? 我當時在想項目文件中的構建后事件,但是我只希望它由特定的TFS構建運行,而不是針對所有構建。

我在項目文件中使用此鈎子部署特定的js版本化文件:

<!--Hook to deploy add files -->
<PropertyGroup>
    <CollectFilesFromContentDependsOn>
        AddFilesToDeploy;
        $(CollectFilesFromContentDependsOn);
    </CollectFilesFromContentDependsOn>
</PropertyGroup>
<!--Add files to deploy -->
<Target Name="AddFilesToDeploy">
    <GetAssemblyIdentity AssemblyFiles="$(TargetPath)">
        <Output TaskParameter="Assemblies" ItemName="CurrentAssembly" />
    </GetAssemblyIdentity>
    <ItemGroup>
        <JsFile Include="script\myApp.min-%(CurrentAssembly.Version).js" />
        <FilesForPackagingFromProject Include="%(JsFile.Identity)">
            <DestinationRelativePath>%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
        </FilesForPackagingFromProject>
    </ItemGroup>
</Target>

如果我記得,這對於tfs構建不起作用,因為在此過程中未執行CollectFilesFromContent,因此我已在構建后事件中復制了文件:

if not '$(TeamFoundationServerUrl)' == '' (
    xcopy "$(ProjectDir)script\myApp.min-@(VersionNumber).js" "$(OutDir)_PublishedWebsites\$(MSBuildProjectName)\script"
)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM