-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Make dotnet pack usage more CI / build system friendly #5867
Comments
@yishaigalatzer @emgarten can you guys comment on this? We want to be sure that |
You can use environment variables like you could with DNX: https://github.com/dotnet/cli/blob/rel/1.0.0/src/Microsoft.DotNet.ProjectModel/ProjectReaderSettings.cs |
There is no point in investing in dotnet pack. We are retiring it right after rc in favor of nuget pack |
I do agree with the ask, but there is strong pushback to add replacement parameters to project.json. the package version is easy, it is the dependencies that get super tricky and it leaks into restore |
@smbecker Using DOTNET_BUILD_VERSION is not a solution, because it's for the version suffix, and not for the version itself |
There are two discussions going on, I have an answer for one at the moment (which is current pack is going away). As for your other question (control version on CI) there is no answer yet. I do agree it is a problem that needs resolution. Still debating the design with various team members. The scenario to keep in mind is as such: Project a references project b, both of them produce packages. Hence the version of project b affects packing of project a, which means that we can't just solve this problem at the pack level (since restore treats projects and packages as interchangeable) |
Realize this is an older issue - but as a workaround, I build a custom dotnet-version command, found here: https://github.com/PaulTrampert/dotnet-version/ Just import it in the tools section of your project.json (it's available on nuget), and call it with |
This is now fixed, since Pack is driven by csproj file which can easily include parametarized properties. |
@piotrpMSFT so how does one pass build parameters to |
@tpluscode https://docs.microsoft.com/en-us/nuget/schema/msbuild-targets An example is:
|
So the solution is to not use dotnet pack, but instead use dotnet msbuild ? |
If the arguments available through dotnet pack --help Usage: pack [arguments] [options] [args] |
My goal is to specify the version number, completely (not just a suffix). This would be from a CI build, so the easiest thing is to specify a version in the build configuration as something like 1.0.{0} and have it replace the last number with the build number. Is there any way to specify the version via dotnet pack that I'm not seeing (or another way to do what I'm looking at doing)? |
@ardalis You could introduce an msbuild property for your build number as such: <PropertyGroup>
<BuildNumber Condition=" '$(BuildNumber)' == '' ">0</BuildNumber>
<Version>1.2.$(BuildNumber)</Version>
</PropertyGroup>
|
@ardalis I have since learned that |
Browsing through the code, the command |
Okay, so this works:
Is this is official Microsoft recommendation for specifying the version number via CI build? |
https://github.com/dotnet/cli/issues/2676#issuecomment-214938537 That comment didn't age very well. |
Steps to reproduce
Assume, that have a project.json with a version placeholder (e.g. 1.0.0). It would be nice, if there would be a way for a CI system (like TeamCity) to update this version number without requiring the usage of regular expressions.
Expected behavior
One or more of the following:
$version$
asversion
value.--version
parameterThe
$version$
would get replaced by the version of theAssemblyInformationalVersionAttribute
or (when the former is missing), the value of theAssemblyVersionAttribute
. The--version
parameter would enforce the usage of the given version (and thus overriding the found assembly version).Actual behavior
dotnet pack
uses the version from theproject.json
and the CI system (like TeamCity) must patch theproject.json
, which is error prone, because it must not update theversion
values of dependencies.Environment data
dotnet --info
output:The text was updated successfully, but these errors were encountered: