-
-
Notifications
You must be signed in to change notification settings - Fork 726
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
Add example of how to use Cake with TeamCity #117
Comments
I may contribute to this issue, since I'm now using cake w/ teamcity at work. What particularly were you interested in documenting? Just running a cake script? Or TC <-> cake interactions? |
I am very interested in this feature. If someone can provide a simple, step-by-step document to show how to integrate cake with TC, that will be very helpful. |
@johnxjcheng is there something specific that you are looking for help on? |
Nothing specific. Just something in general. I am not a TC person. I am more a developer and would like to run build from shell. However many companies have SCM teams that take care of building processes. I just want to make sure if I choose to use CAKE, me or someone else can easily integrate it with TC. Hopefully the TC experts may find that’s easy. |
@johnxjcheng we have now applied for a OSS license for TeamCity, when we get that we can setup and document Cake building under that. |
One thing we've done with our TeamCity build server is to incorporate TeamCity's custom MSBuild logger into our Cake script. This way MSBuild errors/warnings are surfaced correctly in the TeamCity dashboard/build log UI. We did this by adding a Param(
...
[string]$MSBuildLogger = "",
...
) that's then forwarded to and parsed by var msBuildLogger = Argument<string>("msBuildLogger"); and used by our MSBuild task wrapper: private void MSBuildTarget(string solution, string configuration, string target)
{
MSBuild(solution, settings => {
settings
.WithTarget(target)
.SetConfiguration(configuration);
if (!string.IsNullOrEmpty(msBuildLogger))
{
Information("Using custom MSBuild logger: {0}", msBuildLogger);
settings.ArgumentCustomization = arguments =>
arguments.Append(string.Format("/logger:{0}", msBuildLogger));
}
});
} And in our TeamCity build config we pass in the appropriate TeamCity system parameters as a script argument to
Ideally the above could be simplified via #473 and/or #702 and possibly by extending |
Here's one happy Cake-TeamCity user that might be able to help if you have any questions. |
Thanks, our SCM guys integrated cake with teamcity without any difficulty. Sent from Outlook Mobile On Mon, Mar 14, 2016 at 1:11 PM -0700, "Martin Björkström" notifications@github.com wrote: Here's one happy Cake-TeamCity user that might be able to help if you have any questions. Reply to this email directly or view it on GitHub: |
Hi, I'm using Cake with TeamCity as well. What have worked out for me is to execute the .ps1 file from a step with the Powershell runner. The output from the build gets nicely outputted in the build log and if any error occurs in the exeuction the build is aborted. /Niklas |
We do similar and we are using our own fork of cake hosted on an internal feed as cake doesn't play well with corporate proxy environments. Our metarunner is here if this helps anyone |
@wwwlicious very interesting! I have started implementing a supported TeamCity Meta Runner here: https://github.com/gep13/cake-teamcity This will eventually make it into the cake org. Would welcome any feedback that you might have. Also, why the need to fork Cake? What changes have you had to make? It is something that we should support better in Cake? |
@gep13 Cool, will keep tabs on the runner's progress, I would recommend submitting a PR for it to the JetBrains MetaRunner Powerpack repo if you haven't already considered this. the reason for the fork I mentioned above is the support around not having internet access on the build servers and therefore the need to grab all resources from internal nuget feeds or repo's. I have a couple of PR's pending (just need to find time to rebase them!) that help with the pre-processor directives and solution package restores but you also need a custom bootstrapper for getting packages.config and nuget.exe from non-internet sources. This was partly the reason for creating a custom metarunner and bootstrapper as mine has alternative paths for these, so I don't have to repeat the customisations again and again for each repo. I'd suggest if you try running cake without internet and cached packages, you'll begin to see why I forked it for yourself. :) |
@wwwlicious I have thought about submitting to the meta runner power pack repo. That is what we did with the GitVersion Meta Runner, however, I think in this case, we would like to "own" the meta runner, and keep it under direct control of the Cake Team, so that if any changes are required, they can be applied immediatley, and not have to wait the time for a PR into that repo to be accepted.
The recent talk that I did at NDC Oslo was done completely offline, with no internet connection. The new settings that were exposed via the config file were enough to allow me to get everything working: http://cakebuild.net/docs/fundamentals/default-configuration-values If there are more things that you need exposed in order to get this to work then we need to hear about them, as this is definitely a scenario that we would like to support. The custom bootstrapper would still be required though. however, this is intended to be "your" bootstrapper. The one that comes from Cakebuild.net, is really just a reference sample. Yip, I ran into the same issues as you, and that was really where the configuration options came from 😄 |
The main issue for me is that you end up having to modify your machine or user level nuget.config file to set the default system sources or rely on package caching, that's what one of my PR's avoid as I think that isn't acceptable to have to custom configure build agent servers. Agree completely about the bootstrapper, it was easiest to just host it, along with our custom packages.config and cake.config files on an internal repo for DRY. Not sure how to reduce friction in this area but perhaps providing override params for bootstrapper paths for nuget.exe, roslyn and nuget sources when installing the bootstrapper script in VS Code. Hit a few snags in lack of support for output params for MSBuild due to it being parsed from Console.Out rather than executed directly against MSBuild dll's, reverting changes to assemblyinfo files after gitversion tasks to avoid erroneous/accidental commit churn and limited support for Octopus Deploy ops beyond push (which we have another PR in for I think) but nothing that you cannot work around. Have to say overall, cake is pretty great and way, way faster to get comprehensive build scripts written than my previous adventures in MSBuild, Psake and Teamcity (using steps, custom runners and plugins) so if I sound like I'm moaning, I am ;) ... but it is with ❤️ |
So, just to confirm, you didn't want to do something like this:
Or are you "solely" using the packages.config file for Tool resolution?
Within VSCode, you can configure the download URL for the bootstapper file that you use: That is what I was doing during my demos, so that when you do this: The bootstrapper is the one that you have hosted "somewhere". Would that help with your scenario?
Glad to hear it!! |
Correct, standard build script across a bunch of repo's has the following and having switched internal nuget feed addresses a couple of times over the years, I don't like hardcoding these things too often.
That's a little gem right there! Yes it would help 👍 |
@wwwlicious gotcha. Just wanted to check that we were on the same page, and sounds like we are. 👍 on using GitVersion! 😄 |
Wonder if something like possibility to expand environment vars would help or confuse, something like #tool nuget:%TOOL_NUGET_FEED_URL%?package=xunit.runner.console most build servers have the possibility to set environment variables shared upon build agents, would also be easy to set conditionally in bootstrapper scripts (i.e. check subnet or similar). |
Sounds like a reasonable option and would avoid commiting paths to a repo which is useful. Creates two different methods of env var evaluation though, one using [Edit] Should add that having an environment variable override in the bootstrapper for nuget.exe, roslyn and packages.config locations would be 👍 |
@devlead hmm, not sure if I like that idea, but willing to be convinced. |
One suggestion is to utilise the teamcity built-in nuget.exe, you can see an example of this in use on my metarunner for xunit where I get both nuget.exe and the xunit runner package from sources configurable per build. |
@wwwlicious ooo, that sounds like a good idea! Any chance you can add that as an issue on that repo, so that I don't forget about it? |
This is my meta runner: https://github.com/dtatcox/meta-runner-power-pack/tree/dtatcox-cake/Cake |
for those of you on this thread that have stated they currently use Team City and Cake, answer me this: did you have a install an edition of the Visual Studio IDE, in order to succesfully execute MSBuild on a solution which has one of the following project types: Web, Data (SqlProj)? Everywhere on the web that i look I am seeing people say that is the way to go, but I find it hard to believe that in 2017, I'm needing to install the full IDE on my build server. Please tell me there's another way, which does NOT involve manually copying a folder from my dev box to the build server so MSBuild via Cake can find the targets files. |
@tafs7 I usually never install full IDE on my build agents, it's often sufficient with the Build Tools (e.g. for VS 2015 I use Microsoft Build Tools 2015) For VS 2017, they seem to have renamed it a bit. Try grabbing "Build Tools for Visual Studio 2017 from here. Select "Other Tools and Frameworks" and "Build Tools for Visual Studio 2017". Additionally for building .SqlProj projects, you might need to reference NuGet package Microsoft.Data.Tools.Msbuild in your solution. You can read about that here |
@mholo65 I've installed both the Microsoft Build Tools 2015 and the Build Tools for VS 2017 on my build agent box, neither of which worked. MSBuild fails when trying to load a target file: Even after installing both of above mentioned build tools, that path does not exist on my server. |
@tafs7 I normally add this package as a dependency of my web projects, it solves this problem - https://www.nuget.org/packages/MSBuild.Microsoft.VisualStudio.Web.targets Definitely frustrating though so I sympathise. Installing the IDE though is never the solution, "the web" is wrong! ;) |
I wrote a short article describing some simple aspects of integration between Cake and TeamCity: https://www.codeproject.com/Tips/1271037/Integration-of-Cake-build-script-with-TeamCity Hope it will be of some help. |
@yakimovim thanks for doing that. Could I get you to do a PR into this page: https://github.com/cake-build/website/blob/develop/input/docs/resources/blogs.md So that people will be able to find this here as well? Thanks |
@gep13 I have created a pull request. |
I stopped working with TeamCity. I will pass this to our build team.
Thanks,
John Cheng
…________________________________
From: yakimovim <notifications@github.com>
Sent: Tuesday, December 11, 2018 3:54:05 AM
To: cake-build/cake
Cc: John Cheng; Mention
Subject: Re: [cake-build/cake] Add example of how to use Cake with TeamCity (#117)
I wrote a short article describing some simple aspects of integration between Cake and TeamCity:
https://www.codeproject.com/Tips/1271037/Integration-of-Cake-build-script-with-TeamCity
Hope it will be of some help.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#117 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AAL2VuU--oWHyNJnJ9NAS5T_khs3gR1Tks5u34C9gaJpZM4C3v3D>.
|
Closing this, as it is a documentation issue which is tracked by cake-build/website#1047 |
No description provided.
The text was updated successfully, but these errors were encountered: