tag:help.appveyor.com,2012-11-13:/discussions/questions/22519-how-to-auto-build-app-y-when-library-x-builds-and-upgrade-app-ys-reference-to-library-x-beforeAppVeyor: Discussion 2018-10-19T08:18:50Ztag:help.appveyor.com,2012-11-13:Comment/456866352018-07-13T12:47:08Z2018-07-13T12:47:13ZHow to auto build App Y when Library X builds (and upgrade App Y's reference to Library X before)?<div><p>Folks -</p>
<p>Whats the best way to structure appveyor projects to handle a situation where we want a successful build of a common library to trigger a couple of other projects that actually consume this library? I have borrowed from the Deployment Project approach and now have the ability to trigger other projects but before those builds are initiated, I want them to upgrade their to the latest version of this common library (which is being exposed via a private nuget account feed on appveyor).</p>
<p>In other words, I would like:<br>
1) a successful build of Library X (generating version N+1) to trigger the build of App Y and App Z 2) but make sure that App Y and App Z have both upgraded their to</p>
<p>All the projects in question are targeting .netcoreapp2.0. And of course App Y and App Z should also do a normal build if any of their direct code base has changed.</p>
<p>Has anyone dealt with this situation and if so - what's the recommended way of handling this?</p>
<p>Thanks very much<br>
Rajiv</p></div>rajivtag:help.appveyor.com,2012-11-13:Comment/456866352018-07-13T18:49:56Z2018-07-13T18:49:56ZHow to auto build App Y when Library X builds (and upgrade App Y's reference to Library X before)?<div><p>Per my knowledge <code><PackageReference Include="Library X" Version="*"/></code> should always restore latest package, can you try <code>"*"</code> instead of <code>"N"</code>?</p></div>Ilya Finkelshteyntag:help.appveyor.com,2012-11-13:Comment/456866352018-07-15T19:44:53Z2018-07-15T19:46:24ZHow to auto build App Y when Library X builds (and upgrade App Y's reference to Library X before)?<div><p>Thanks Ilya! While '*' doesn't seem to work, other format variations such as Major.minor work. The full reference: <a href="https://docs.microsoft.com/en-us/nuget/reference/package-versioning#version-ranges-and-wildcards">https://docs.microsoft.com/en-us/nuget/reference/package-versioning...</a></p></div>rajivtag:help.appveyor.com,2012-11-13:Comment/456866352018-07-24T01:41:33Z2018-07-24T01:41:33ZHow to auto build App Y when Library X builds (and upgrade App Y's reference to Library X before)?<div><p>Re-opening this because although the native PackageReference capabilities of including version N or higher (instead of a precise version) work fine, the overall solution isn't working.</p>
<p>The expected mechanics here are:<br>
a) Library X is currently at Version 2.1.73<br>
b) App Y and App Z both include<br>
c) Library X build is triggered and this generates a new version 2.1.74<br>
d) Library X build completion triggers the build of App Y and App Z<br>
e) I would expect App Y and App Z to resolve to Library X Version 2.1.74<br>
f) But it does not. It still resolves to 2.1.73</p>
<p>Is there some sort of delay in Version 2.1.74 to become visible in the private Nuget feed for our Appveyor account? Could that be the reason why its not resolving to the latest version?</p>
<p>Thanks very much<br>
Rajiv</p></div>rajivtag:help.appveyor.com,2012-11-13:Comment/456866352018-07-24T11:36:16Z2018-07-26T17:37:03ZHow to auto build App Y when Library X builds (and upgrade App Y's reference to Library X before)?<div><p>Yes it can be a delay. Sorry I should have mention this earlier. AppVeyor uploads nuget artifacts to feed asynchronously. So successful artifact upload does not mean that package is available in account feed immediately.</p>
<p>I recommend first rerun builds for App Y and App Z manually and if you see that they now take Version 2.1.74, then indeed problem is a delay. In this case I propose the following workaround:</p>
<ul>
<li>
<p>pass expected new version to newly created build as environment variable. Please see <a href="https://gist.github.com/IlyaFinkelshteyn/89d19593318276e2538040787bc4fce7">this sample</a></p>
</li>
<li>
<p>Add a blocking script to <code>init</code> stage which will wait this version to appear in <code>nuget list</code> output. Something like this:</p>
</li>
</ul>
<pre>
<code>$found = $false
while (!$found) {
$found = nuget list -source <appveyor_account_feed> | ? {$_.Contains($env:ExpectedVersion)}
}</code>
</pre>
<p>Where <code>ExpectedVersion</code> is environment variable passed when starting build. You also will probably make this script more verbose and add some timeout to avoid infinite loop, but you got the idea.</p>
<p>Let us know if this works for you.</p></div>Ilya Finkelshteyntag:help.appveyor.com,2012-11-13:Comment/456866352018-07-24T12:47:35Z2018-07-24T12:47:35ZHow to auto build App Y when Library X builds (and upgrade App Y's reference to Library X before)?<div><p>Thanks Ilya. Since this is obviously a private nuget feed, how would we pass the credentials in a non-interactive mode to that nuget list -source command? And preferably not as clear text.</p></div>rajivtag:help.appveyor.com,2012-11-13:Comment/456866352018-07-24T13:26:30Z2018-07-24T13:26:30ZHow to auto build App Y when Library X builds (and upgrade App Y's reference to Library X before)?<div><p>I do not think you need to pass them as you should have already configured <a href="https://www.appveyor.com/docs/nuget/#configuring-appveyor-nuget-feeds-for-your-builds">nuget feed</a> for App Y and App Z projects. But for other cases like this it is useful to be aware of <a href="https://www.appveyor.com/docs/build-configuration/#secure-variables">secure variables</a>.</p></div>Ilya Finkelshteyntag:help.appveyor.com,2012-11-13:Comment/456866352018-07-26T17:08:35Z2018-07-26T17:16:43ZHow to auto build App Y when Library X builds (and upgrade App Y's reference to Library X before)?<div><p>Thanks Ilya. After trying a few things - I managed to get that working. Now the only issue left is that these builds of App Y and App Z are being triggered even if the build of Library X fails. I am using on_success. Is there a different key to use in the yaml ?</p>
<pre>
<code>on_success:
- ps: Start-AppveyorBuild</code>
</pre>
<p>Thanks<br>
Rajiv</p></div>rajivtag:help.appveyor.com,2012-11-13:Comment/456866352018-07-26T17:19:58Z2018-07-26T17:19:58ZHow to auto build App Y when Library X builds (and upgrade App Y's reference to Library X before)?<div><p><code>on_success</code> should not be called if build fails. When you are saying "build of Library X fails", does this mean that AppVeyor build is "red"? Or maybe script building Library X fails but swallows error somehow and AppVeyor build is actually "green"?</p></div>Ilya Finkelshteyntag:help.appveyor.com,2012-11-13:Comment/456866352018-07-26T17:30:03Z2018-07-26T17:30:03ZHow to auto build App Y when Library X builds (and upgrade App Y's reference to Library X before)?<div><p>Never mind - I tried to reproduce what I saw yesterday and unable to do so. All is well. Thanks again for your help!</p></div>rajivtag:help.appveyor.com,2012-11-13:Comment/456866352018-07-26T17:40:43Z2018-07-26T17:40:43ZHow to auto build App Y when Library X builds (and upgrade App Y's reference to Library X before)?<div><p>You are welcome! Also App Y and App Z can be triggered in case they are in the same repo as X, simple by webhook. In this case, you can use <a href="https://www.appveyor.com/docs/how-to/filtering-commits/#commit-files-github-and-bitbucket-only">commit files filtering</a>.</p></div>Ilya Finkelshteyntag:help.appveyor.com,2012-11-13:Comment/456866352018-07-26T19:53:06Z2018-07-26T19:53:06ZHow to auto build App Y when Library X builds (and upgrade App Y's reference to Library X before)?<div><p>Thanks Ilya. In this case they are not in the same repo. A related question: Just like we can trigger an appveyor build using Start-Appveyor-Build, is there an equivalent Cancel-Appveyor-Build which we could use to stop any already running builds (since they will be triggered again by Start-Appveyor-Build anyway)?</p></div>rajivtag:help.appveyor.com,2012-11-13:Comment/456866352018-07-26T22:36:38Z2018-07-26T22:36:38ZHow to auto build App Y when Library X builds (and upgrade App Y's reference to Library X before)?<div><p>There is no such command (and build worker API), but you can this with service <a href="https://www.appveyor.com/docs/api/projects-builds/#cancel-build">REST API</a>. However you have to know build version of the build you need to cancel. What is bigger scenario here? Maybe you can simple set up <a href="https://www.appveyor.com/docs/build-configuration/#rolling-builds">rolling builds</a>?</p></div>Ilya Finkelshteyntag:help.appveyor.com,2012-11-13:Comment/456866352018-07-26T22:52:33Z2018-07-26T22:52:33ZHow to auto build App Y when Library X builds (and upgrade App Y's reference to Library X before)?<div><p>Thanks again! I wasn't aware of the Rolling Builds feature - thats exactly the behavior I was looking for i.e. if multiple back to back commits are resulting in the same projects being built, cancel everything except the latest commit.</p>
<p>Also Build Prioritization is a nice feature that I'm trying out to ensure stuff in a dependency chain that's auto triggered gets built in the right order.</p></div>rajiv