(This article also published in my public number "dotnet daily Essence article", Welcome to the right QR code to pay attention to. )
Preface: This is a simple getting Started wizard that involves GitHub, Appveyor, and nuget.org.
The recent development of staples related to the simple packaging of a nail SDK and open source (Https://github.com/keyroads/DingtalkSDK), which involves continuous integration and automatic release of NuGet package issues. Previously, I used TFS or VSTS to do CI, and since it's a Open source project hosted on GitHub, choose one of the Appveyor and Travis Ci (I chose the appveyor because it's right) from the common continuous integration platform. NET project to do a lot of convenient support). At the same time this is a library of functions, so it also needs to be automatically published to nuget.org (of course myget) for those who need it.
Here is the exact step (journal):
1, managed code to GitHub (nonsense), it is recommended to set master as the main branch.
2, to Https://ci.appveyor.com/signup registered users, select "Free" program, login can choose GitHub account, so convenient and better integration.
3, on the Appveyor project page https://ci.appveyor.com/projects, create a new project, select GitHub, and select one of the listed repositories (Repository). Note: If you have previously logged in to Appveyor with a GitHub account, you will be listed here on GitHub (if you need to select an organization's project, then the authorization is also granted to the organization), if you do not sign in with a GitHub account, Then there should be a process for integrating with the GitHub account.
4, after selecting "NEW" in step 3, Appveyor uses some default parameters to set up the project right away. At this time, it is theoretically possible to carry out CI properly. But a lot of the time, we still need to do some personalized configuration. Configuration of the Appveyor, Can be configured based on the YML format file (Appveyor.yml,appveyor can be automatically read in the repository root directory, you can also set the path and file name of the Appveyor.yml file), or can be configured based on the user interface. Both coexist, the file method defaults to the user interface mode, but the user interface mode has the option (General > Ignore appveyor.yml) can ignore the file mode.
5, my own personalized configuration is as follows:
5.1, the same repository I built two CI projects, one for continuous integration (each commit and PR will be built, named build), one for "continuous delivery" (Push tag, Build and deploy the NuGet package to nuget.org, named Publish.
5.2, first say the configuration of the build project. In the General section: I checked the "pull requests don't increment build number" to avoid the build numbers being disrupted by the not-yet-accepted PR; "Branches to Build" select "Only Branches Specified below "input" Master "represents only changes to the master branch; tick" Do not build tags "because tag is handled by the Publish project; tick" Fetch repository as Zip Archive "enables faster code acquisition when the project code is historically long; tick" Ignore appveyor.yml ". In the build section: "Configuration" input "Release", "Before Build script" select cmd and enter "dotnet Restore" and "nuget Restore" two lines, There is dotnet because I have a version of. NET core in my dingtalksdk.
The configuration of the 5.3,publish project is based on the build project, but changes or joins the following configuration. General section: Uncheck "Do not build tags" and tick "build tags only" to push the tag (that is, when a version needs to be published) to trigger CI; enable "AssemblyInfo patching" Let the release of the NuGet package version be changed. Build section: Tick "package nuget projects" to let Appveyor automatically generate NuGet packages for you (explained in more detail below). Artifacts section: Add a ARTIFACT, enter "Temp_path\*.nupkg" in "PATH to ARTIFACT", enter "Nuget DEPLOYMENT" in "Packages NAME", "type" select " Auto ". In the Deployment section: Add a Deployment, "Deployment provider" select "NuGet", enter nuget.org obtained from Api-key to "API key", "Artifact (s)" Input "/." *\.nupkg/".
6, the above mentioned publish this CI project is automatically released NuGet package to nuget.org. With the help of Appveyor, this process is actually very simple.
6.1, download Nuget.exe (https://dist.nuget.org/win-x86-commandline/latest/nuget.exe).
6.2, go to the project folder that needs to be packaged as NuGet, run "NuGet spec" to generate a packaged description Nuspec file for the current project. Edit the generated nuspec files to your own needs, such as adding dependencies. Refer to (HTTPS://DOCS.NUGET.ORG/NDOCS/SCHEMA/NUSPEC) for details.
6.3. Include the Nuspec file in the source code (note in the project root directory, i.e., with the csproj file) and submit it to GitHub. This is a critical step in making Appveyor's "package NuGet projects" option work. By enabling this option, Appveyor will automatically build a NuGet package for this project and put it in the "Temp_path" directory, so you need to add this NuGet package to the build output artifact.
6.4, to the nuget.org website, registered account (you can directly use the Microsoft account to log in). You can then obtain the API KEY (required in the deployment configuration of Appveyor) in (Https://www.nuget.org/account).
7, the final thing is to show the build status to the project homepage on GitHub. This is also very simple, in the Appveyor in each project configuration has a badges section, the "Sample markdown code" copied to the readme.md will be done.
At this point, a. NET open source function library project is automatically built and deployed to this configuration. Of course, since DINGTALKSDK has no real support for. NET core, it does not take into account the NuGet packaged configuration of. NET Core.
How to continuously integrate/deliver an open source. NET function library to nuget.org