2016-05-05 8 views
0

私はmsbuildスクリプトを使用してssrsレポートを展開しています。以前はすべてのレポートが1つのフォルダにありましたが、これらのレポートをレポートサーバーに展開するにはmsbuildスクリプトを作成しました。今度は、customer service, inventoryinvoiceというフォルダレベルのレポートを管理しています。Msbuildを使用してフォルダを操作するには?

これらの個々のフォルダをレポートサーバーに展開する方法は?レポートサーバーでも、フォルダレベルの階層が必要です。

+0

詳細を入力しないと手伝ってもらえません。あなたは何を持っていますか(脚本)?解決したい問題は何ですか? MsBuildを使用すると、フルパス、相対パス、ワイルドカード、再帰的なディレクトリなどを扱うことができます。 – Rolo

答えて

0

msbuildのコピータスクを使用して1つのフォルダコピーを行っていましたか?もしそうなら、同じタスクをフォルダ構造全体をコピーするためにちょっと修正するのは大したことではありません。この例に似た何か:

<Copy SourceFiles="c:\src\**\*.txt" DestinationFolder="c:\dest\%(RecursiveDir)"></Copy> 

%(RecursiveDir)ソースファイルのパラメータからワイルドカードの値が含まれますよく知られているアイテムのメタデータのタイプです。ここでMSBuildよく知られているアイテムのメタデータのビットより多くの説明があります:

MSBuild well known item metadata


完全な例:ここでは

<?xml version="1.0" encoding="utf-8"?> 
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> 
    <ItemGroup> 
    <Sources Include="c:\src\**\*.txt" /> 
    </ItemGroup> 
    <Target Name="copy-folder"> 
    <Copy SourceFiles="@(Sources)" DestinationFolder="c:\dest\%(RecursiveDir)"></Copy> 
    </Target> 
</Project> 
+0

ここでは、 "在庫"としてフォルダ名を取得していますが、出力から "\"を取り除く方法はありますか? –

+0

後ろにスラッシュを付ける理由がわかりません。あなたの質問を編集し、フォルダ構造と正確なmsbuildスクリプトを記述すると、助けが簡単になります。 - 私は簡単に私のための再帰的なコピーを達成する完全な例を示すために私の答えを編集しました。 – xianwill

0

は、再帰的なファイルコピーの例です。

保存 "FileCopyRecursive.msbuild"(またはFileCopyRecursive.proj)と呼ばれるファイルに以下

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

    <PropertyGroup> 
     <!-- Always declare some kind of "base directory" and then work off of that in the majority of cases --> 
     <WorkingCheckout>.</WorkingCheckout> 
     <WindowsSystem32Directory>c:\windows\System32</WindowsSystem32Directory> 
     <ArtifactDestinationFolder>$(WorkingCheckout)\ZZZArtifacts</ArtifactDestinationFolder> 
    </PropertyGroup> 

    <Target Name="AllTargetsWrapped"> 

     <CallTarget Targets="CleanArtifactFolder" /> 
     <CallTarget Targets="CopyFilesToArtifactFolder" /> 
    </Target> 

    <Target Name="CleanArtifactFolder"> 

     <RemoveDir Directories="$(ArtifactDestinationFolder)" Condition="Exists($(ArtifactDestinationFolder))"/> 
     <MakeDir Directories="$(ArtifactDestinationFolder)" Condition="!Exists($(ArtifactDestinationFolder))"/> 
     <RemoveDir Directories="$(ZipArtifactDestinationFolder)" Condition="Exists($(ZipArtifactDestinationFolder))"/> 
     <MakeDir Directories="$(ZipArtifactDestinationFolder)" Condition="!Exists($(ZipArtifactDestinationFolder))"/>    
     <Message Text="Cleaning done" /> 
    </Target> 

    <Target Name="CopyFilesToArtifactFolder"> 

     <ItemGroup> 
      <MyExcludeFiles Include="$(WindowsSystem32Directory)\**\*.doesnotexist" /> 
     </ItemGroup> 

     <ItemGroup> 
      <MyIncludeFiles Include="$(WindowsSystem32Directory)\**\*.ini" Exclude="@(MyExcludeFiles)"/> 
     </ItemGroup>   

     <Copy 
       SourceFiles="@(MyIncludeFiles)" 
       DestinationFiles="@(MyIncludeFiles->'$(ArtifactDestinationFolder)\%(RecursiveDir)%(Filename)%(Extension)')" 
     /> 

     </Target> 

    </Project> 

次に、この実行します。

"C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" /target:AllTargetsWrapped FileCopyRecursive.msbuild /l:FileLogger,Microsoft.Build.Engine;logfile=AllTargetsWrapped.log 

BONUSを!

"fun with files" msbuildファイルです。

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

    <Target Name="AllTargetsWrapper"> 
     <CallTarget Targets="FunWithFilesTask" /> 
    </Target> 

    <PropertyGroup> 
     <WorkingCheckout>c:\windows\System32</WorkingCheckout> 
    </PropertyGroup> 

    <!-- =====================================================      --> 

    <!-- 
     See: 
     http://msdn.microsoft.com/en-us/library/ms164313.aspx 

     *Identity Value for the item specified in the Include attribute. 
     *Filename Filename for this item, not including the extension. 
     *Extension File extension for this item. 
     *FullPath Full path of this item including the filename. 
     *RelativeDir Path to this item relative to the current working directory. 
     *RootDir Root directory to which this item belongs. 
     RecursiveDir Used for items that were created using wildcards. This would be the directory that replaces the wildcard(s) statements that determine the directory. 
     *Directory The directory of this item. 
     AccessedTime Last time this item was accessed. 
     CreatedTime  Time the item was created. 
     ModifiedTime Time this item was modified. 

    --> 


    <Target Name="FunWithFilesTask"> 

     <ItemGroup> 
      <MyExcludeFiles Include="$(WorkingCheckout)\**\*.doesnotexist" /> 
     </ItemGroup> 

     <ItemGroup> 
      <MyIncludeFiles Include="$(WorkingCheckout)\**\*.ini" Exclude="@(MyExcludeFiles)" /> 
     </ItemGroup> 

     <PropertyGroup> 
      <MySuperLongString>@(MyIncludeFiles->'&quot;%(fullpath)&quot;')</MySuperLongString> 
     </PropertyGroup> 

     <Message Text="MySuperLongString=$(MySuperLongString)"/> 
     <Message Text=" "/> 
     <Message Text=" "/> 

     <Message Text="The below items are good when you need to feed command line tools, like the console NUnit exe. Quotes around the filenames help with paths that have spaces in them. "/> 
     <Message Text="I found this method initially from : http://pscross.com/Blog/post/2009/02/22/MSBuild-reminders.aspx  Thanks Pscross! "/> 
     <Message Text=" "/> 
     <Message Text=" "/> 

     <Message Text="Flat list, each file surrounded by quotes, with semi colon delimiter: "/> 
     <Message Text="   @(MyIncludeFiles->'&quot;%(fullpath)&quot;')"/> 
     <Message Text=" "/> 
     <Message Text=" "/> 

     <Message Text="Flat list, each file surrounded by quotes, no comma (space delimiter): "/> 
     <Message Text="   @(MyIncludeFiles->'&quot;%(fullpath)&quot;' , ' ')"/> 
     <Message Text=" "/> 
     <Message Text=" "/> 

     <Message Text="Flat list, each file surrounded by quotes, with comma delimiter: "/> 
     <Message Text="   @(MyIncludeFiles->'&quot;%(fullpath)&quot;' , ',')"/> 
     <Message Text=" "/> 
     <Message Text=" "/> 

     <Message Text="List of files using special characters (carriage return)"/> 
     <Message Text="@(MyIncludeFiles->'&quot;%(fullpath)&quot;' , '%0D%0A')"/> 
     <Message Text=" "/> 
     <Message Text=" "/> 

    </Target> 

</Project> 
関連する問題