-
Notifications
You must be signed in to change notification settings - Fork 258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issues with PackTask and packing NuSpec #4250
Comments
@natemcmaster PackItem is supposed to be a csproj, it can be left blank and it will infer the csproj if you are in the same directory. The only thing that changes when packing with a nuspec file is /p:NuspecFile is passed . NuspecOutputPath and RestoreOutputPath pick up default values from the csproj file based on the value of BaseIntermediateOutputPath Can you attach a repro project where you are repro'ing these issues? |
I'm not using csproj. I'm trying to write an MSBuild target for our build system. See https://github.com/aspnet/Common/tree/119fa62786b414157a11a21f1aa8b586fe355d44/shared. Instead of shelling out to NuGet.exe, I'm trying to use PackTask directly. For more context, here is the code (that worked in 4.0.0-rc2) that I'm trying to replace with RC3 bits: <ItemGroup>
<Packages Include="$([System.IO.Directory]::GetDirectories("$(MSBuildThisFileDirectory)", '*.Sources'))" />
</ItemGroup>
<Exec Command="dotnet nuget pack
"$(MSBuildThisFileDirectory)sources.nuspec"
--base-path "%(Packages.Identity)"
--version $(Version)
--output-directory "$(OutputPath)"
--properties "id=%(Packages.FileName)%(Packages.Extension)""
/> Here's the nuspec: <?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>$id$</id>
<version>$version$</version>
<authors>Microsoft</authors>
<owners>Microsoft</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>$id$</description>
<contentFiles>
<files include="contentFiles/cs/**/*.cs" buildAction="Compile" />
<files include="**/*.resx" buildAction="EmbeddedResource" />
</contentFiles>
</metadata>
<files>
<file src="**\*.resx" target="contentFiles/any/netstandard1.0/" />
<file src="**\*.cs" target="contentFiles/cs/netstandard1.0/" />
</files>
</package> I would have expected to replace shelling out to NuGet.exe with something like this: <PackTask NuspecFile="myfile.nuspec"
PackageVersion="$(Version)"
PackageOutputPath="$(ArtifactsPath)"
Properties="var_name=var_value" /> But as I tried do this, I ran into the issue described above. |
@natemcmaster This won't work if you call the PackTask directly. You need to still call dotnet pack as a command and pass in /p:NuspecFile="path to nuspec file" . Most likely the current version of dotnet you are using doesn't have the updated nuget which supports packing from nuspec file, but we are in the process of creating one and you should be able to use it tomorrow. |
To clarify, is it not working because |
@natemcmaster yes. you should only use dotnet pack as the entry point for anything related to pack. i have identified some of the issues that you are facing here, and we are trying to determine at this point whether we can fix them for 4.0.0-RTM or whether we need to put them in the next milestone. |
Spoke with @rohit21agrawal in person and tried some of the private builds he was working on. They seem to fix the issues we are having. To move ASP.NET Core's build forward, we need fixes for RTM. |
@rrelyea any chance we can try this for RTM ? I am ready to send out a PR for this. |
Let's review the design on the team. Your current design:
|
Although PackTask supports passing in a nuspec file directly, this task is still very hard to use and is pretty buggy. Here are some issues I encountered while trying to replace 'dotnet nuget pack *.nuspec' with 'PackTask' (4.0.0-rc3-2193).
Unclear usage:
PackItem = This is required, but when packing a nuspec, what should this be set to?
Properties replacement = how to specify variable properties? NuGet.exe supports variable substitution.
NuspecOutputPath = Causes NRE if unset, but doesn't make sense in this context.
RestoreOutputPath = Causes NRE if unset, but doesn't make sense in this context.
These properties, when set on the PackTask, should override what is in the nuspec but do not.
PackageVersion
PackageId
Description
Combined with the lack of property replacement, it makes it impossible to pack a nuspec that is defined with variable substitution for required metadata. E.g.
cc @rohit21agrawal
The text was updated successfully, but these errors were encountered: