简体   繁体   中英

Create multi-target nuget package from several csproj contained in different folders from nuspec file

I am trying to create a nuget package for a library which exists in 2 versions, each of them targeting two different .NET versions.

Here is my folder structure:

在此处输入图片说明

As you can see my nuspec file is one directory above my csproj (which are in the /net452 and /netcoreapp2.0 folders).

I am using the following command line to build my nuget package:

nuget pack .\\my.nuspec -properties Configuration=Release -Build

The issue is that the build can not be achieved because the csproj files are not in the same folder as the nuspec file.

Please note that the packaging works fine when both projects have been priorly manually built.

I'm very new to this process and I'm not sure what I should do in that scenario, is there a simple way to reference the 2 csproj from the nuspec or - assuming I want to keep this folder structure - would I need to make a script that builds the projects first and then invoke nuget pack ?

EDIT : To clarify my issue, I do have two different csproj files, contained respectively in /net452 and /netcoreapp2.0, and they compile the source code in their respective directory to produce two different dll. These two dll are then referenced in my nuspec file in order to offer my package in net452 or netcoreapp2.0 with the following syntax:

  <files>
    <file src="lib\**" target="lib" />
  </files>

Note: after I manually compiled my two projects, the directory looks like this (note the lib folder that contains a net452 and netcoreapp2.0 folder with the appropriate version of my dll).

在此处输入图片说明

Not sure if understood correctly - you have one library and want to build it in two versions (net452 and netcore).

Did you try adding following items to *.csproj?

<PropertyGroup>
    <TargetFrameworks>net45;netcoreapp2.0</TargetFrameworks>
</PropertyGroup>

Then you can have on project with two outputs from build

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