简体   繁体   English

将一个项目的 output 目录中的一个文件复制到另一个项目的 output 目录

[英]Copy one file from a project's output directory to another project's output directory

Given:鉴于:
Visual Studio 2019 solution Visual Studio 2019 解决方案
2.Net Core Projects 2.Net核心项目
Needs to work in Azure Pipelines需要在 Azure 管道中工作
Needs to work locally需要在当地工作

Goal is to copy a single file from one project's bin to another project's bin.目标是将单个文件从一个项目的 bin 复制到另一个项目的 bin。 I need it to work on my local machine and in Azure Pipelines.我需要它在我的本地机器和 Azure 管道中工作。

SolutionFolder  
  Project_1_DotNetCore31  
  Project_2_DotNetCore31  

I would like to copy a single file我想复制一个文件

From

Project_1_DotNetCore31\bin\Debug\netcoreapp3.1\TargetFile.txt  

To

Project_2_DotNetCore31\bin\Debug\netcoreapp3.1\TargetFile.txt  

I've tried a couple of things:我尝试了几件事:

  1. Post Build Event in Project 2项目 2 中的后期构建事件

    copy $(SolutionDir)Project_1_DotNetCore31\$(outputDir)TargetFile.txt $(outputDir)复制 $(SolutionDir)Project_1_DotNetCore31\$(outputDir)TargetFile.txt $(outputDir)

This works locally on my development machine but not in Azure Pipelines.这在我的开发机器上本地工作,但不适用于 Azure 管道。 $(SolutionDir) becomes undefined. $(SolutionDir) 变得未定义。

  1. Post Build Event in Project 2项目 2 中的后期构建事件

    copy "..\..\..\..\Project1\bin\$(ConfigurationName)\netcoreapp3.1\TargetFile.txt TargetFile.txt复制“..\..\..\..\Project1\bin\$(ConfigurationName)\netcoreapp3.1\TargetFile.txt TargetFile.txt

This didn't work work locally or in Azure DevOps but if I paste it into a command prompt it works fine.这在本地或 Azure DevOps 中不起作用,但如果我将其粘贴到命令提示符中,它工作正常。

  1. I looked into Azure Copy Files task and I don't understand it.我查看了 Azure 复制文件任务,但我不明白。

Looking for suggestions, would like to learn how to use Azure Copy Files task寻求建议,想学习如何使用 Azure 复制文件任务

Try xcopy.试试 xcopy。 I had something like below as post build event of project 1. Did not test with Azure Pipelines though.作为项目 1 的构建后事件,我有类似下面的内容。虽然没有使用 Azure 管道进行测试。

xcopy "$(TargetDir)TargetFile.txt" "$(SolutionDir)EvenHubListener\$(OutDir)"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将exe从一个项目复制到另一个项目的调试输出目录 - Copy exe from one project to another's debug output directory Nuget库-将库的DLL复制到当前项目的输出目录 - Nuget Library - Copy DLL of Library to current project's output directory .NET Core:将 Config.json 等任意文件复制到项目的输出目录 - .NET Core: Copy Arbitrary file like Config.json to Project's Output Directory 从另一个项目的类获取一个项目的基本目录 - Get Base Directory of one project from another project's class 保存/检索项目目录中的文件,而不是输出目录中的文件 - Save/retrieve a file in a project directory, not the output directory Nuget包将exe内容文件复制到项目输出目录 - Nuget package to copy exe content file to project output directory 项目输出目录中缺少DLL - DLLs Missing From Project Output Directory 如何将.exe从C ++项目复制到C#项目的输出目录? - How to copy .exe from C++ project to the output directory of a C# project? 将一个项目的输出复制到另一项目的输出 - Copy output of one project to output of other project 将 nuget package 内容文件(类型为.exe)复制到使用该 nuget package 的项目的 output 目录 - Copy nuget package content file (of type .exe) to output directory of project using that nuget package
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM