Deploy ARM Template with Octopus Deploy in a Package - visual-studio

I have a created an ARM template in Visual Studio, and I need to package the JSON files so that I can use the option in Octopus Deploy to deploy the JSON files within the ARM template as a package - as described in the following link, under section 'Template Contained in a Package
https://octopus.com/docs/deploying-applications/azure-deployments/resource-groups
The problem is that I don't know what application in Visual Studio to package the application? I did some research and I read that the best package to use in nuspec as described here:
https://dinventive.com/blog/2016/10/20/5-steps-and-under-30-minutes-to-deploy-arm-templates-via-octopus-deploy/
However, there are a whole bunch of nuspec applications. The closet I got to what I need is the NuGetToolsPackager, as shown in the image.
nuget
However, if there are any other suggestions, they will be most welcome.

The link you provided shows how to create the package from a build server (in this case VSTS), which is the recommended way to go. Packaging + building should be orchestrated from a build server, and not from and IDE if possible :)
That said, one good way to do this from Visual Studio would be to add a dependency to the OctopusTools package which will download Octo.exe during your build. Then you can add a post-build script that calls Octo.exe pack to create your package, and then Octo.exe push to push it to a repository.
Documentation for Octo.exe pack: https://octopus.com/docs/packaging-applications/creating-packages/nuget-packages/using-octo.exe
Documentation for Octo.exe push: https://octopus.com/docs/api-and-integration/octo.exe-command-line/pushing-packages

Related

Azure Artifact Nuget package debugging issue

I'm using Azure Pipeline to build and publish NuGet packages to the Azure Artifact feed. The pipeline includes the Publish Symbols task as below:
- task: PublishSymbols#2
inputs:
SearchPattern: '**/bin/**/*.pdb'
SymbolServerType: 'TeamServices'
However, when installing the package into the sample console app I can not debug the package (the body of the methods is not visible).
I'm using C# .NET Core 3.1
Pipeline Type: YAML
Used this article to config the Visual Studio
https://learn.microsoft.com/en-us/azure/devops/artifacts/symbols/setting-up-github-sourcelinking?view=azure-devops
For those who face this issue needs to take into consideration some issue/case related to Azure DevOps API and the Symbol file (PDB) packaging mechanism. The PDB contains the information regarding all the cs files regarding the package and because the package packing process is done on the Agent itself the information regarding the cs files is like this: $(Build.SourcesDirectory)/RepoName/SomeDirectory/File.cs
However, when the Visual Studio tries to download the file (the reference is in the PDB file) from the Azure DevOps API, it can not find the file. Because the API wants to get the cs file like this: https://azureDevOpsAPIURI/OrganizationID/RepoID/path=/SomeFirectory/File.cs
And this is a conflict between API and PDB files' reference. I have managed to solve this problem by Moving all the CS files from the Agent's checkout path to $(Build.SourcesDirectory) in order to get rid of the RepoName in the call to Azure DevOps API. I'm not sure if it's a conflict or there is a native way to do this or no.

Difference in nugets processing via `dotnet add package ..` vs nugets adding via visual studio UI

I need to use native c libraries in my library(that supports several Core TFs and .net framework) which is published via nuget. I configured it via .csproj file and runtimes folder. But I noticed that when I consume my NuGet via dotnet add package .. in some cases, the native libraries are not copied into the expected folder after consuming, however when I use the VS UI Nuget package manager->Manage Nuget Packages for Solution, all files are placed into correct places.
So, I assume that Nuget package manager makes more steps than just call dotnet add package .., but it's unclear what exactly happens, any help will be appreciated.
Actually, dotnet add package does the same effect as Nuget package manager UI in VS IDE. They simply install a Nuget package into your project and there is no difference. No additional operations will be performed. Like add some xml node in
So I think there is something else wrong in your project.
Please check under tips to troubleshoot your issue:
1) clean nuget caches first or just delete all cache files under C:\Users\xxx(current user)\.nuget\packages.
2) And if the runtimes folder does not exist under your project, I think it is controlled by dependency assets. Like ExcludeAssets=runtime or native. It will prevent the function of runtimes folder. Please see this official document.
So after you finishing installing the nuget package, you should check your csproj file, and make sure that there is no such like
<ExcludeAssets>runtime;native</ExcludeAssets>
under PackageReference node.
If there is any this node, please delete it.
3) delete bin and obj folder. Then rebuild your project to test again. Or if you use dotnet command line, you should additionally add dotnet build command. In my side, I run dotnet build -p:platform=xxx;Configuration=Release.

TeamCity Nuget feed viewing

So maybe I'm a little bit confused about how a nuget server works and the specifics of nugets in general.
I am setting up octopus deploy and TeamCity for my company and have run into a bit of a snag. I am trying to set up a deployment where I deploy a website and a service in the same release, however, Octopus can't seem to find the nuget package. It throws the following error:
Could not find any packages with ID 'PackageName' in the feed 'octopus://'
I am able to see the package when I test the feed in octopus, and I verified that I am using the correct ID in teamcity. Basically what I've been trying to research is how I can view all of my nugets in the feed. Is that a thing? I am using TeamCity as the Nuget server and I know with octopus you can view all packages that have been pushed to its repository. Am I able to view all packages in the TeamCity Nuget server? I want to verify that my package is there.
In order for Octopus to be able to publish the package, it needs it to be set to build an OctoPack.
To get this working, use the NuGet package manager for the project in question and add a reference to 'OctoPack'.
Bear in mind that if you have a Visual Studio solution containing several packages and you want several of these to be deployable packages you will have to add OctoPack to each project you want as a deployable package.
Include Octopack in the project to build the nuget package.
Use this parameter with MSBuild to automatically push the package to the destination nuget gallery after the build is complete.
/p:OctoPackPublishPackageToHttp=http://my-nuget-server/api/v2/package

Publishing NuGet Packages - TeamCity

I have just setup TeamCity to automate our builds, our current solution has both a dev and main branch. What I am trying to achieve is to have the development branch build and publish to a development NuGet feed on our ProGet installation, and then have the main branch publish to our Main NuGet feed on ProGet server.
We are using octopus deploy to deploy the packages, within TeamCity we have the octopus deploy plugin installed and if I tick the box to run OctoPack it builds the packages and they appear as artifacts when the build completes. If I try to use the NuGet Pack build step in TeamCity I get the following error for one of our projects:
[08:33:49] : [pack] Attempting to build package from 'xxx.csproj'.
[08:33:50]W: [pack] Unable to find 'xxx.exe'. Make sure the project has been built.
The project has been built and it works with OctoPack so why isn't it working with the NuGet Pack? Wwe have five projects being built and the first four run fine, one is a console app, one is an mvc website, and two are class libraries. The one that doesn't work is a windows service.
The end goal here is to publish these packages to a private feed on ProGet. I don't mind using OctoPack but in my head wanted to remove that dependency from TeamCity but I can live with it. However when I try to use the NuGet Publish runner type how do I select to publish any NuGet artifacts that have been created?
I have been googling like mad and I cannot find any helpful links that describe what you are supposed to enter, I would really appreciate any helpful comments/answers.
We are using version 8.15 of TeamCity.
Hopefully the following will help with at least part of your question; mainly the bit relating to how to publish packaged artifacts.
NuSpec Approach
When using the NuGet Pack build step, you can specify the Output Directory, which will determine the output location of the packages. You can specify this as a relative path to the checkout directory, probably best to define it as a build parameter, such as %system.PackageDeployOutput% as you'll be using it in the next step...:
Next, specify a NuGet Publish build step, fill in the Package Source / API key etc, and specify the Packages to upload as
%system.PackageDeployOutput%\*.nupkg
This will pick up the packages output in the previous step. I've used this quite effectively, and the parameterisation approach encourages conventions across all your builds.
OctoPack Support
If you're using the MsBuild build step with OctoPack, you can use a similar approach by declaring a system parameter called
system.OctoPackPublishPackageToFileShare = %teamcity.build.checkoutDir%\%system.PackageDeployOutput% (note the same parameter as above)
You can declare these as root project parameters, so you get the best of both worlds. My preferred approach to packaging is currently to use nuspec files for deployable endpoints. I've found OctoPack to be a bit of an overhead when it comes to more complex deployments (it's fine for basic MsBuild projects).

How do I integrate NuGet into my Bamboo Build Plan?

Our build plans for Sitecore (.Net) websites are currently using Bamboo as the build plan master for continuous integration process. Bamboo supports building a .Net project, and that .Net project contains references to several Sitecore binaries.
I have used NuGet as an artifact repository, mostly because that seemed to be the one most people were using.
So, now that I have a nuget repository, am hosting my own feed, and have added the Nuget package to my project (I just installed the package of binaries I created), what more do I need to do?
Should the build call out something special, or am I done? I guess I'm just nervous that bamboo isn't talking directly to my repository....
In the closest analogy I have, namely a Maven/Archiva combo, the maven plan specifically references the artifacts in archiva, pulling the correct version as needed. Does NuGet do this?
Since there have been some new developments in the NuGet package restore approach, I thought I'd post an update on this topic. We're using Visual Studio 2012. I wanted to be able to run MSBuild and make sure that it would first restore NuGet packages without setting "Package restore" to true in the config. Here's what I did (inspired by https://stackoverflow.com/a/23935892/414376):
Upgraded NuGet in my solution to a version later than 2.7 (2.8.3 in my case; this seems like an optional step)
Installed NuGet.exe on the build server
Added NuGet.exe to my remote agent so that it could be run as a command from Bamboo
Added the NuGet command to my build plan with argument restore (so that the command will be nuget restore); I've placed it right before my MSV Build task.
That was all I needed to get this to work properly according to the latest guidelines.
Nuget 1.4+ supports "Package restore" which embeds a call to an MsBuild task in the project file. When the packages are not available it will automatically restore them while building the project.
I'm sure this is old news, but my packages are in \packages. No amount of "dotnet restore" would work, until I explicitly mentioned the packages folder.
dotnet restore --packages .\packages
restored them!
VS2019. just in case it's version specific.

Resources