kay*_*eck 1 nuget nuget-package nuget-spec .net-standard
如何打包在 CSProj 文件中具有 Nuget 规范的 .NET Standard NuGet 包而不重建它?
\n\n我有一些自动化需要在构建步骤和打包步骤之间运行,这些自动化与构建过程本身分离,并且不应该是与任何项目相关的构建事件。
\n\n当我尝试使用 nuget CLI 时,它失败并显示以下内容:
\n\nError NU5012: Unable to find \'bin\\Debug\\LibraryNuGetExample\\bin\\Debug\\\'. Make sure the project has been built.
这没有任何意义,因为那不是构建输出文件夹!正确的输出文件夹是bin\\Debug\\**——我不明白为什么它要寻找我没有在任何地方指定的目录映射。
我尝试使用这个,但它重建了,我绝对不想要;只是nuget pack:
MSBuild LibraryNuGetExample.csproj /t:pack
所以我要么需要知道如何,
\n\nLibraryNuGetExample.csproj
<Project Sdk="Microsoft.NET.Sdk">\n\n <PropertyGroup>\n <TargetFrameworks>uap10.0;net45</TargetFrameworks>\n <PackageId>LibraryForNuGetExample</PackageId>\n <Authors>user name</Authors>\n <Company>ACME</Company>\n <Product>Library For NuGet Example</Product>\n <Description>A test package to test automation.</Description>\n <Copyright>ACME \xc2\xa9 2018</Copyright>\n <PackageTags>DevOps Builds Testing</PackageTags>\n <PackageVersion>$(AssemblyVersion)</PackageVersion>\n <Platforms>x64;AnyCPU</Platforms>\n <NeutralLanguage>en-US</NeutralLanguage>\n </PropertyGroup>\n\n <PropertyGroup Condition="\'$(TargetFramework)\' == \'uap10.0\'">\n <NugetTargetMoniker>UAP,Version=v10.0</NugetTargetMoniker>\n <TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>\n <TargetPlatformVersion>10.0.15063.0</TargetPlatformVersion>\n <TargetPlatformMinVersion>10.0.15063.0</TargetPlatformMinVersion>\n <TargetFrameworkIdentifier>.NETCore</TargetFrameworkIdentifier>\n <TargetFrameworkVersion>v5.0</TargetFrameworkVersion>\n <DefineConstants>$(DefineConstants);WINDOWS_UWP</DefineConstants>\n <LanguageTargets>$(MSBuildExtensionsPath)\\Microsoft\\WindowsXaml\\v$(VisualStudioVersion)\\Microsoft.Windows.UI.Xaml.CSharp.targets</LanguageTargets>\n </PropertyGroup>\n\n <ItemGroup>\n <None Include="LibraryForNuGetExample.targets" Pack="true" PackagePath="build\\uap10.0" />\n </ItemGroup>\n\n <ItemGroup Condition=" \'$(TargetFramework)\' == \'uap10.0\' ">\n <PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform " Version="5.2.2" />\n </ItemGroup>\n\n <ItemGroup>\n <Reference Include="Windows">\n <HintPath>C:\\Program Files (x86)\\Windows Kits\\10\\UnionMetadata\\10.0.15063.0\\Windows.winmd</HintPath>\n <IsWinMDFile>true</IsWinMDFile>\n <Private>true</Private>\n </Reference>\n </ItemGroup>\n\n <Target Name="CopyPackage" AfterTargets="Pack" Condition="\'$(IsCrossTargetingBuild)\' == \'true\'">\n <Copy SourceFiles="$(OutputPath)$(PackageId).$(PackageVersion).nupkg" DestinationFolder="$(SolutionDir)Packages" />\n </Target>\n\n</Project>\nRun Code Online (Sandbox Code Playgroud)\n\nLibraryForNuGetExample.targets
<?xml version="1.0" encoding="utf-8" ?>\n<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\n <ItemGroup Condition="\'$(TargetPlatformIdentifier)\' == \'UAP\'">\n <ReferenceCopyLocalPaths>\n Include="$(MSBuildThisFileDirectory)bin\\Release\\uap10.0\\LibraryNuGetExample.dll"\n Include="$(MSBuildThisFileDirectory)bin\\Release\\uap10.0\\LibraryNuGetExample.pdb"\n Include="$(MSBuildThisFileDirectory)bin\\Release\\uap10.0\\LibraryNuGetExample.pri"\n </ReferenceCopyLocalPaths>\n </ItemGroup>\n <ItemGroup Condition="\'$(TargetPlatformIdentifier)\' == \'NET45\'">\n <ReferenceCopyLocalPaths>\n Include="$(MSBuildThisFileDirectory)bin\\Release\\net45\\LibraryNuGetExample.dll"\n Include="$(MSBuildThisFileDirectory)bin\\Release\\net45\\LibraryNuGetExample.pdb"\n Include="$(MSBuildThisFileDirectory)bin\\Release\\net45\\LibraryNuGetExample.pri"\n </ReferenceCopyLocalPaths>\n </ItemGroup>\n</Project>\nRun Code Online (Sandbox Code Playgroud)\n
您可以使用相当于
dotnet pack --no-build
Run Code Online (Sandbox Code Playgroud)
对于 MSBuild(因为您正在为 UAP 构建)是
msbuild -t:Pack -p:NoBuild=true
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
914 次 |
| 最近记录: |