Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/286.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# msbuild中的项组_C#_.net_Msbuild_Copy - Fatal编程技术网

C# msbuild中的项组

C# msbuild中的项组,c#,.net,msbuild,copy,C#,.net,Msbuild,Copy,我有以下项目组: <ItemGroup> <ReleaseFiles Include="MyApp\*.ashx"/> <ReleaseFiles Include="MyApp\*.config"/> <ReleaseFiles Include="MyApp\bin\*.dll"/> <ReleaseFiles Include="MyApp\bin\*.exe"/> <ReleaseFi

我有以下项目组:

  <ItemGroup>
    <ReleaseFiles Include="MyApp\*.ashx"/>
    <ReleaseFiles Include="MyApp\*.config"/>
    <ReleaseFiles Include="MyApp\bin\*.dll"/>
    <ReleaseFiles Include="MyApp\bin\*.exe"/>
    <ReleaseFiles Include="MyApp\bin\*.pdb"/>
    <ReleaseFiles Include="MyApp\bin\*.config"/>   
  </ItemGroup>

以及以下复制目标:

<Copy SourceFiles="@(ReleaseFiles)" DestinationFiles="@(ReleaseFiles->'\\$(DeploymentMachine)\C$\Program Files\MyApp\%(RecursiveDir)%(Filename)%(Extension)')" />

但问题是bin目录没有被保留(所有文件最终都在顶层目录中)

请注意,我需要使用相同的项目组来创建zipfile:

<Zip Files="@(ReleaseFiles)" ZipFileName="$(server)\$(BUILD_NUMBER).$(BUILD_VCS_NUMBER)\myApp.zip" WorkingDirectory="MyApp"/>


这很好用。我怎样才能使副本也正常工作?

在您的

<ReleaseFiles/>

中断递归

试试这个:

<ItemGroup>
    <ReleaseFiles Include="MyApp\**\*.ashx" />
    <ReleaseFiles Include="MyApp\**\*.config" />
    <ReleaseFiles Include="MyApp\**\*.dll" />
    <ReleaseFiles Include="MyApp\**\*.exe" />
    <ReleaseFiles Include="MyApp\**\*.pdb" />
    <ReleaseFiles Include="MyApp\**\*.config" />
</ItemGroup>

<Copy SorceFiles="@(ReleaseFiles)" DestinationFiles="@(ReleaseFiles->'\\$(DeploymentMachine)\C$\Program Files\MyApp\%(RecursiveDir)%(Filename)%(Extension)')" />

希望这能解决你的问题

更新


我刚读到,这也可能导致这个问题。。。但是应该是

您需要让MSBuild引擎认为
bin
是递归文件夹的一部分。为此,在bin文件夹后添加一个
*
,如下所示:

<ItemGroup>
    <ReleaseFiles Include="MyApp\*.ashx"/>
    <ReleaseFiles Include="MyApp\*.config"/>
    <ReleaseFiles Include="MyApp\bin*\*.dll"/>
    <ReleaseFiles Include="MyApp\bin*\*.exe"/>
    <ReleaseFiles Include="MyApp\bin*\*.pdb"/>
    <ReleaseFiles Include="MyApp\bin*\*.config"/>   
</ItemGroup>


我刚刚重读了Filburt的答案,这应该也行,但在这种情况下,如果您在其他文件夹中有具有相同扩展名(dll、exe、pdc、config)的文件,它们也会被拾取。因此递归通配符“**”中有一个含义因为有些人声称使用MyApp**.ashx或MayApp***.ashx没有任何区别。我从未见过三星
***
,但
***
的意思是匹配任何东西,包括子文件夹,
*
是匹配同一文件夹中的任何东西(不要在子文件夹中递归)。
%(ReleaseFiles.RecursiveDir)
元数据将包含从
Include
属性中的路径段开始的路径,该属性包含
*
**
。当它。。。别管三星了。我没能逃脱刀砍。评论应该是“MyApp”[slash][star][star][slash][star]。.ashx”。