Atualmente, estou no processo de mover os projetos de biblioteca de classes compartilhadas da minha empresa de referências de projetos para referências de pacotes NuGet. Tive sucesso ao converter todos os projetos, exceto um, que é um projeto VB.NET mais antigo direcionado ao .NET v4.7.2. Não recebo erros durante a compilação ou empacotamento e o pacote foi criado com sucesso, mas há uma série de DLLs externas e o arquivo PDB que preciso copiar para o pacote NuGet.
Aqui está o arquivo .nuspec:
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>Project.Core</id>
<version>$version$</version>
<title>$title$</title>
<authors>Author Here</authors>
<owners>Owner Here</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>$description$</description>
<releaseNotes>Initial release.</releaseNotes>
<copyright>Copyright © 2019</copyright>
</metadata>
<files>
<file src="bin\$configuration$\Project.Core.pdb" target="lib\net472" />
<file src="bin\$configuration$\FirstExternal.dll" target="lib\net472" />
<file src="bin\$configuration$\SecondExternal.dll" target="lib\net472" />
<file src="bin\$configuration$\ThirdExternal.dll" target="lib\net472" />
<file src="bin\$configuration$\FourthExternal.dll" target="lib\net472" />
<file src="bin\$configuration$\FifthExternal.dll" target="lib\net472" />
<file src="bin\$configuration$\SixthExternal.dll" target="lib\net472" />
</files>
</package>
e aqui está o arquivo do projeto:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>
</RootNamespace>
<AssemblyName>Project.Core</AssemblyName>
<Description>Core Class Library.</Description>
<MyType>Windows</MyType>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>AssemblyKey.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<MapFileExtensions>true</MapFileExtensions>
<UseApplicationTrust>false</UseApplicationTrust>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<DefineDebug>true</DefineDebug>
<DefineTrace>true</DefineTrace>
<OutputPath>bin\Debug\</OutputPath>
<DocumentationFile>Project.Core.xml</DocumentationFile>
<NoWarn>41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42353,42354,42355</NoWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<CodeAnalysisRuleSet>..\StyleCop-Recommended.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<DefineTrace>true</DefineTrace>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DocumentationFile>Project.Core.xml</DocumentationFile>
<NoWarn>41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42353,42354,42355</NoWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<CodeAnalysisRuleSet>..\..\StyleCop-Recommended.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
{Some more configuration definitions.}
<PropertyGroup>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<ItemGroup>
{Bunch of NuGet references.}
<Reference Include="FirstExternal">
<HintPath>..\Lib\FirstExternal\FirstExternal.dll</HintPath>
</Reference>
<Reference Include="SecondExternal, Version=1.2.2389.14294, Culture=neutral, PublicKeyToken=60064b713d9de8f4, processorArchitecture=MSIL">
<HintPath>..\Lib\SecondExternal\1.2\SecondExternal.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<Private>True</Private>
</Reference>
<Reference Include="ThirdExternal, Version=11.1.0.0, Culture=neutral, PublicKeyToken=6d02be8724ca751c, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Lib\ThirdExternal\6.5\ThirdExternal.dll</HintPath>
</Reference>
<Reference Include="FourthExternal, Version=6.4.0.0, Culture=neutral, PublicKeyToken=6d02be8724ca751c, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Lib\FourthExternal\6.5\FourthExternal.dll</HintPath>
</Reference>
<Reference Include="FifthExternal, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Lib\FifthExternal\2.0.5\FifthExternal.dll</HintPath>
</Reference>
<Reference Include="SixthExternal">
<HintPath>..\Lib\SixthExternal\0.3.5_projectCustom\SixthExternal.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.configuration" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.EnterpriseServices" />
<Reference Include="System.Net.Http, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="System.Runtime.Serialization">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="System.ServiceModel">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="System.Transactions" />
<Reference Include="System.Web" />
<Reference Include="System.Web.ApplicationServices" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Web.Services" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
<Import Include="Microsoft.VisualBasic" />
<Import Include="System" />
<Import Include="System.Collections" />
<Import Include="System.Collections.Generic" />
<Import Include="System.Data" />
<Import Include="System.Diagnostics" />
<Import Include="System.Linq" />
<Import Include="System.Windows.Forms.ComponentModel.Com2Interop" />
</ItemGroup>
<ItemGroup Label="CodeFiles">
{Lots and lots of compile elements.}
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="My Project\Resources.resx">
<Generator>VbMyResourcesResXFileCodeGenerator</Generator>
<CustomToolNamespace>My.Resources</CustomToolNamespace>
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<LastGenOutput>Resources.Designer.vb</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="Resources\Messages.resx">
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="My Project\Application.myapp">
<Generator>MyApplicationCodeGenerator</Generator>
<LastGenOutput>Application.Designer.vb</LastGenOutput>
</None>
<None Include="My Project\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<CustomToolNamespace>My</CustomToolNamespace>
<LastGenOutput>Settings.Designer.vb</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<WebReferences Include="Web References\" />
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Service References\" />
</ItemGroup>
<ItemGroup>
<Folder Include="Folder\SubFolder\" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.VisualBasic.targets" />
</Project>
Eu executo o seguinte comando: nuget pack .\Path\To\Project\Project.vbproj -Properties Configuration=Debug -OutputDirectory E:\Local\Nuget-Repo -Verbosity detailed
mas apenas a DLL do projeto e o arquivo XML de documentação são colocados na pasta lib\net472 do nupkg.
Lembre-se de que este projeto é muito anterior ao meu tempo na empresa. Portanto, pode haver elementos muito antigos no arquivo do projeto com os quais não estou familiarizado.
NuGet Version: 5.0.2.5988
Microsoft (R) Build Engine version 16.1.76+g14b0a930a7 for .NET Framework
Por favor, deixe-me saber se há alguma informação extra necessária.
Responder1
Configurei um novo projeto VB.NET e testei o comando pack com essencialmente o mesmo arquivo .nuspec e funcionou perfeitamente.
Após uma investigação mais aprofundada, descobri que o nome do arquivo do projeto deve corresponder exatamente ao nome do arquivo .nuspec. Renomeei meu arquivo .nuspec para corresponder ao nome do arquivo do meu projeto e agora funciona.