How do I pack a package with multiple objects in MSBuild 15?

I am using the new MSBuild 15, distributed with VS2017 RC, to compile and package a multi-targeted project.

Recovery: msbuild /t:restore mysolution.sln working correctly.

Building: msbuild /p:Configuration=Release mylibrary.csproj works correctly and generates:

 + bin/Release + netstandard1.4 - mylibrary.dll + net452 - mylibrary.dll 

But when I pack: msbuild /t:pack /p:Configuration=Release /p:IncludeSymbols=true mylibrary.csproj structure doesn’t work well with the previous assembly, looking like:

 + bin/Release + netstandard1.4 - mylibrary.pdb + net452 - mylibrary.pdb - mylibrary.dll 

Warnings from the /t:pack command show me that this should happen, but don’t know how to solve it:

 C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets(73,5): warning : Issue found with package 'MyLibrary'. [D:\XXX\YYY\src\MyLibrary\MyLibrary.csproj] C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets(73,5): warning : Issue: Assembly not inside a framework folder. D:\XXX\YYY\src\MyLibrary\MyLibrary.csproj] C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets(73,5): warning : Description: The assembly 'lib\MyLibrary.dll' is placed directly under 'lib' folder. It is recommended that assemblies be placed inside a framework-specific folder. C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets(73,5): warning : Solution: Move it into a framework-specific folder. If this assembly is targeted for multiple frameworks, ignore this warning. 

Notes:

I do not use the *.nuspec file. Only new *.csproj files *.csproj ( https://docs.nuget.org/ndocs/schema/msbuild-targets#pack-target )

Here's what the relevant content in the file looks like:

 <Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <OutputType>library</OutputType> <TargetFrameworks>netstandard1.4;net452</TargetFrameworks> <AssemblyName>MyLibrary</AssemblyName> <Authors>XXX</Authors> <Description>YYY</Description> <PackageId>MyLibrary</PackageId> <PackageVersion>1.2.3</PackageVersion> </PropertyGroup> </Project> 
+5
source share
1 answer

Thanks for your comments. I found my way based on them.

This is what I did: I downloaded the dotnet cli tool again and tested it from scratch. I realized that the cli tool version was the same, so I started comparing the files inside.

Invalid clnet dotnet version

The version that did not work contained the following files:

 + dotnet + sdk + 1.0.0-preview2-1-003177 + 1.0.0-preview2-003131 + 1.0.0-preview2-003133 + 1.0.0-preview4-004233 

Using dotnet build /t:pack /p:Configuration=Release /p:IncludeSymbols=true mylibrary.csproj showed the following error:

 Couldn't find 'project.json' in '/t:pack' 

Nice version of dotnet cli

The second version I downloaded contained only the following:

 + dotnet + sdk + 1.0.0-preview4-004233 

And executing the command earlier, it works correctly:

 Microsoft (R) Build Engine version 15.1.458.808 Copyright (C) Microsoft Corporation. All rights reserved. ... 
0
source

Source: https://habr.com/ru/post/1262937/


All Articles