简体   繁体   中英

Azure Pipeline (DotNetCoreCLI@2) include DLL into nuget

In the process of upgrading a codebase/pipelines to Do.net Core. A project has some c++ code in a oldcode.dll file that it needs to be included.

Our old 'pack' pipeline looks something like:

- task: NuGetCommand@2
  inputs:
    command: 'pack'
    packagesToPack: '**/ProjectName.csproj'
    buildProperties: '-IncludeReferencedProjects'

That generated a nuget with the following folder structure:

>build
--->oldcode.dll
--->project.targets

>lib
--->net472
------>project.dll
------>project.pdb
------>project.xml

Upgrading the project to Do.netcore and using this pipeline does not include the oldcode.dll into the nuget

- task: DotNetCoreCLI@2
  inputs:
    command: 'pack'
    packagesToPack: '**/ProjectName.csproj'

I have read about the missing IncludeReferencedProjects function in DotNetCore https://github.com/NuGet/Home/issues/3891

What is the simplest workaround for this case? Could I somehow copy the oldcode.dll into the nuget before going to push ?

UPDATE---- I have tried this:

  • Setting the.nuspec directly into packagesToPack didnt work.

and gives an error:

task: DotNetCoreCLI@2
inputs:
command: 'custom'
custom: 'pack **/NameOfFile.nuspec'


##[error]Error: The process 'C:\Program Files\dotnet\dotnet.exe' failed with exit code 1

Is it the path i'm doing wrong?

This might be what I need to do, if I can figure out how to get the paths done right https://learn.microsoft.com/en-us/nuget/reference/msbuild-targets#packing-using-a-nuspec

dotnet pack <path to .csproj file> -p:NuspecFile=<path to nuspec file> -p:NuspecProperties=<> -p:NuspecBasePath=<Base path> 

You can still use a .nuspec package with do.net core even if you generally don't need to.

So create a file manually, include a <file> element and call pack on that rather than the project:

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
    <metadata>
    <!-- Required elements-->
    <id></id>
    <version></version>
    <description></description>
    <authors></authors>

    <!-- Optional elements -->
    <!-- ... -->
    </metadata>
    <!-- Optional 'files' node -->
    <files>
        <file src="oldcode.dll" target="lib" />
    </files>
</package>

You may be able to sub the .nuspec. file for the csproj file in the packagesToPack argument, but if not, you can use a custom argument.

- task: DotNetCoreCLI@2
  inputs:
    command: 'custom'
    custom: 'pack path/to/Myproject.nuspec'

Paths should be relative to the repository root, so

Root
|
|__MySolutionFolder
   |
   |__MyProject
      |
      |__ProjectName.csproj
      |__ProjectName.nuspec

Should be a relative path of./MySolutionFolder/MyProject/ProjectName.nuspec

IIRC using forward slashes is always safe, but backwards slashes only work on Windows agents

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