현재 회사의 공유 클래스 라이브러리 프로젝트를 프로젝트 참조에서 NuGet 패키지 참조로 이동하는 중입니다. .NET v4.7.2를 대상으로 하는 이전 VB.NET 프로젝트인 프로젝트를 제외한 모든 프로젝트를 성공적으로 변환했습니다. 빌드 또는 팩 중에 오류가 발생하지 않고 패키지가 성공적으로 생성되었지만 NuGet 패키지에 복사해야 하는 일련의 외부 DLL과 PDB 파일이 있습니다.
.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>
프로젝트 파일은 다음과 같습니다.
<?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>
다음 명령을 실행합니다. nuget pack .\Path\To\Project\Project.vbproj -Properties Configuration=Debug -OutputDirectory E:\Local\Nuget-Repo -Verbosity detailed
하지만 프로젝트용 DLL과 문서 XML 파일만 nupkg의 lib\net472 폴더에 저장됩니다.
이 프로젝트는 제가 회사에 근무하기 훨씬 이전에 이루어졌다는 점을 명심하세요. 그래서 프로젝트 파일에는 제가 익숙하지 않은 아주 오래된 요소가 있을 수도 있습니다.
NuGet Version: 5.0.2.5988
Microsoft (R) Build Engine version 16.1.76+g14b0a930a7 for .NET Framework
추가로 필요한 정보가 있으면 알려주시기 바랍니다.
답변1
새로운 VB.NET 프로젝트를 설정하고 기본적으로 동일한 .nuspec 파일을 사용하여 pack 명령을 테스트했는데 제대로 작동했습니다.
추가 조사를 통해 프로젝트 파일 이름이 .nuspec 파일 이름과 정확히 일치해야 한다는 사실을 발견했습니다. 내 프로젝트 파일의 이름과 일치하도록 .nuspec 파일의 이름을 바꾸었고 이제 작동합니다.