简体   繁体   中英

Upload excel spreadsheet as an Azure DevOps source file in C# automation project

I have a C# Excel automation project that runs in a release pipeline and resides in the same repo as my production code, though in a different solution file. I would like to have the automation project use canned Excel workbooks as a starting point for the automation instead of creating new workbooks and dynamically populating cells with user defined function calls.

The automation project is an NUnit test project that compiles into a DLL and I want to have a separate directory of workbooks that is not compiled into the automation DLL.

My question is on the best way to do this. Should I just include a folder of Excel workbooks in my automation project.

How do I get these files into the build pipeline so that the release pipeline has access to them along with the MSI install file and the automation DLL? This assumes that I should implement this as part of the build pipeline instead of downloading the files as part of the release pipeline process triggered by the build pipeline.

The automation project is an NUnit test project that compiles into a DLL and want to have a separate directory of workbooks that is not compiled into the automation DLL.

If I am not misunderstand this requirement, you want this workbook can exist with Dlls, but don't want it be compiled.

In Visual studio, there has a option can achieve the similar feature.

Right click the excel file -> Properties , and choose the corresponding action about Copy to Output Directory :

在此处输入图像描述

Corresponding to this operation, the.csproj file will be added some scripts:

  <ItemGroup>
    <None Update="MyFile.xlsx">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
  </ItemGroup> 

Using <CopyToOutputDirectory> to determines whether this file would be copied to the output directory where the Dlls located. In your requirement, here you should specify the workbook.


Same in Azure Devops Service, if you add the above script into .csproj by specifying the corresponding workbook. Then this workbook will be generated into the output folder together with the dlls . The most important things is that this workbook will not be compiled, because it just be copied into the output.

Just configure the build pipeline as normal, along with using Publish Build artifacts task to pack these output. Then the release pipeline would get and access it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM