Msbuild 将文件复制到输出目录issue.targets文件

Msbuild 将文件复制到输出目录issue.targets文件,msbuild,.net-5,Msbuild,.net 5,我使用目标文件在运行时生成一些文件,并将它们从中间目录(obj)复制到bin 我的环境是.Net 5和相应的MSBUILD版本 一般来说,我的.targets文件工作正常,但我有一个问题: 当文件在中间目录中生成时,它们会保存在类似于obj/x64/Debug/…FileName.fx的路径中,而整个路径正是复制到bin文件夹中的输出。 例如,我的原始文件位于Effects/BasicEffect.fx中,我想将此结构保留在输出中,但它会复制到obj/x64/Debug/Effects/Basi

我使用目标文件在运行时生成一些文件,并将它们从中间目录(obj)复制到bin

我的环境是.Net 5和相应的MSBUILD版本

一般来说,我的.targets文件工作正常,但我有一个问题:

当文件在中间目录中生成时,它们会保存在类似于
obj/x64/Debug/…FileName.fx的路径中,而整个路径正是复制到bin文件夹中的输出。
例如,我的原始文件位于
Effects/BasicEffect.fx
中,我想将此结构保留在输出中,但它会复制到
obj/x64/Debug/Effects/BasicEffect.fxo
,最终路径是:
bin/x64/Debug/obj/x64/Debug/Effects/BasicEffect.fxo
,这就是我想要修复的

这是我的目标文件:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

   <ItemGroup>
      <AvailableItemName Include="Effect"/>
      <!--<AvailableItemName Include="Font"/>-->
   </ItemGroup>
    
   <!-- In Project A -->  
    <UsingTask Architecture="*" TaskName="EffectCompilerTask" AssemblyFile="$(SolutionDir)CompilerTask\bin\Debug\net5.0\CompilerTask.dll"/>
    <UsingTask Architecture="*" TaskName="CompilerDependencyTask" AssemblyFile="$(SolutionDir)CompilerTask\bin\Debug\net5.0\CompilerTask.dll"/>
  
   <!-- 1st PART : When Project A is built, It will generate effectively the files -->
   <!-- Plugs all dependency listing in AssignTargetPathsDependsOn - in order to support generated output to be copied as part of the build  -->
   <PropertyGroup >
      <BuildDependsOn>
         EngineCompileTarget;
         $(BuildDependsOn);
      </BuildDependsOn>


      <IsBuildInDebug>true</IsBuildInDebug>

      <!--By default turn-on debugging on fx files when compiling in debug (no optimize)-->
      <EngineEffectDebugOption Condition="'$(EngineEffectDebugOption)' == ''">$(IsBuildInDebug)</EngineEffectDebugOption>

      <EffectDynamicCompilingOption Condition="'$(EffectDynamicCompilingOption)' == ''">$(IsBuildInDebug)</EffectDynamicCompilingOption>

      <GenerateCsFileFromEffect>false</GenerateCsFileFromEffect>
      <GenerateBinaryFromEffect>true</GenerateBinaryFromEffect>
      <GenerateCsFileFromFont>false</GenerateCsFileFromFont>
      <GenerateBinaryFromFont>true</GenerateBinaryFromFont>
      <CompileFontBitmaps>false</CompileFontBitmaps>
      
   </PropertyGroup>
    <Target Name="EngineContentAndCompileTarget" BeforeTargets="Build">
        <CompilerDependencyTask
                ProjectDirectory="$(ProjectDir)"
                IntermediateDirectory="$(IntermediateOutputPath)"
                Files="@(Effect)"
        >
            <Output ItemName="EngineContent" TaskParameter="ContentFiles" />
        </CompilerDependencyTask>

        <ItemGroup>
            <!--List Of fx compiled file-->
            <Content Include="@(EngineContent)" KeepMetadata="CopyToOutputDirectory"/>
        </ItemGroup>

    </Target>
    
<!-- Target used to calculate dependency output -->
   <Target Name="EngineCompileTarget" BeforeTargets="Build">
      <EffectCompilerTask
          Files="@(Effect)"
          ProjectDirectory="$(ProjectDir)"
          IntermediateDirectory="$(IntermediateOutputPath)"
        >
         </EffectCompilerTask>
         
      <Message Text="Hello from EngineCompileTarget" Importance="High"></Message>
      <Message Text="EngineCompileTarget @(Content)" Importance="High"></Message>
   </Target>

</Project>

有人能告诉我这里缺少什么,以便在保存原始文件结构的情况下正确地将生成的文件复制到输出吗?

也许您可以使用
XCOPY
来执行此操作。例如,我将整个文件夹复制到输出目录中。但是文件夹已经存在。我不确定它是否适用于生成的文件

属性下
► <代码>生成事件
► <代码>生成后事件命令行我执行以下操作:

XCOPY "$(ProjectDir)myFolder" "$(TargetDir)myFolder" /s /i /y

我认为这不是一个选项,因为文件是在中间目录中生成的,并将自动复制到output CallYok,但我将把它留在这里。也许其他人需要这个选择。
XCOPY "$(ProjectDir)myFolder" "$(TargetDir)myFolder" /s /i /y