AppOffline rule issue w/ Continuous Integration/Build - continuous-integration

I've connected Visual Studio Team Services to an Azure Website to enable automatic deployments. New Relic is running as a system process and therefore NewRelic.Agent.Core.dll is locked which prevents successful builds from being deployed.
I've tried adding a wpp.targets file to the solution in order to utilize MSDeploy to copy an app_offline document to the site before deployment, then delete it when deployment is done like seen here. However, it doesn't seem as if it is executing. I don't see anything in the build logs and my deployments continue to fail.
How do I take the app offline when using the VS Team Services/Azure CI process?

I came across this old post and there are now build tasks to start and stop an app service. See the Azure App Service Manage under the deployment tasks in the build task catalog.

Slightly different to what you are asking but what you could do is to login to your Azure website and set COR_ENABLE_PROFILING to 0 before your build runs. You then deploy as normal. Once done you set COR_ENABLE_PROFILING back to 1.
The act of changing the setting will cause an IIS reset and setting it to zero will disable the file from being locked again before the publish finishes.
Source: https://discuss.newrelic.com/t/visual-studio-online-azure-website-continuous-integration-fails/3825

Related

Specflow tests running on local web server

I am trying to use Specflow with Playwright in order to do BDD on a portal app developed but I am facing a small problem.
The Specflow project is a separate project with the ASP.Net core server that has the Api of the portal app (it is in Vue). Since the tests are pointing to a specific URL (currently localhost), before running the tests, I need to run the ASP.Net core & Vue project locally. Otherwise, Specflow & Playwright will not be able to do the test (as it will not find the localhost).
Is it any way I can force the run of the Web Server project? I tried to run it from outside Visual Studio with dotnet build and then dotnet run commands but somehow they are missing parameters (that exist while running it from inside VS) and apart from that, these commands must somehow be triggered while trying to run the tests.
I have seen solutions like creating a Docker image from a Docker Compose file in order to pack a .Net project & server in it before running the Specflow tests. Then in the BeforeTestRun hook using the FluentDocker to spin-up the server but I am not quite sure it is the easier (or best) solution.
Does anyone know how I can trigger running the .net core project (with the Vue pages)?
This is actually a pretty big question, with a pretty big answer, however this is well-trodden ground. The issue isn't so much a "specflow" issue as a general automated testing issue. Development practices like continuous integration and continuous delivery can help. Each one is too big for a single question, however I can answer this in more general terms.
In its simplest form, running automated tests locally involves these steps:
Build the application
Deploy the application to a real web server
Run tests
I'm going to assume you are developing in a Windows environment, however every operating system has some sort of command line scripting solution available. The scripting language might change, but the overall idea will not.
Configure a web server. In Windows, this would be Internet Information Services (IIS).
Add a new "application" (or "IIS app" as some people call it) to your localhost web server. Point the physical directory to the root directory for the web project. Repeat this for each web site or web app your system requires.
Write a PowerShell script that gives you an easy way to build and deploy the applications to your local web server.
This script should use publish profiles set up in Visual Studio, which allows you to publish directly from Visual Studio before invoking tests manually through Test Explorer.
Write a PowerShell script used has a "harness" script to coordinate building, deploying locally, and then invoking dotnet test.
Running tests locally just requires a single line of PowerShell to invoke your test harness script:
.\Scripts\Run-Tests.ps1 -solutionDir . -tags BlogPosts,Create
# Skip deploying in case web apps haven't changed:
.\Scripts\Run-Tests.ps1 -solutionDir . -tags BlogPosts,Create -deploy:False

AzureDevOps / Executing the pipelines locally with Visual Studio 2019

I would like to duplicate the build process (with pipelines) from Azure DevOps to my PC with Visual Studio 2019.
This could save time and git ops during the debugging/evolving phase of the pipelines.
Is that possible?
This has been requested many times in many places, and I think that, given Microsoft's push toward Github, you may not see a lot of effort in this direction.
Right now, I don't think you'll be able to able to use VS 2019 to directly debug pipelines, but you can do a couple of things as a workaround:
Put your build process into a Powershell script and debug that process using VS Code or Powershell ISE. Then, set up your Azure Pipelines build to invoke that script. Your pipeline, and local build then are using the same mechanism to build.
This is more to be able to test outside any existing pipelines you may have.
2a. Create a new agent pool for testing local pipelines.
2b. Install the Azure Pipelines agent code, and when configuring the agent, point it to the agent pool you just created.
2c. In a topic branch for your project, change the pool in your azure-pipelines.yml file to use the agent pool you just created.
2d. Commit and push that branch.
2e. Manually queue up a build of your project, selecting the branch you just pushed.
2f. Debug. Wash. Rinse. Repeat
2g. Once you've got it all sorted out, you can revert the azure-pipelines.yml pool change, and commit/PR the Powershell script you created.
The second option doesn't really speak directly to your question, rather it adds one more thing you can do to help with the first option - getting everything tested locally.

Deploy to Azure marks (Release Annotation) from desktop

Is there any way to look for deployment event from Visual Studio in Azure? I would like to see when we deployed.
Previously, we had that option in Application Insight, now that they removed that feature I don't know where to look.
I would've expected to find that information, i.e., deployment/publish history in Azure Activity Logs or Deployments under the corresponding Resource group, but couldn't, and began digging further.
AFAIK, there isn't a straightforward way of tracking manual deployments on Azure. However, I can think of two workarounds:
Using VS Code: When a deployment is manually performed using VS Code using the Azure App Service extension, it becomes easier to track the deployment history and also see the current/active version, along with various other configuration options and logs. For example:
Using the KUDU console: Browse to the deployments page within the Kudu console for your app service (would be of the form: https://{app-name}.scm.azurewebsites.net/api/deployments), and you should see the history in JSON format. For example:
Note: I'd strongly advise using the same mode of deployment always, for maintaining consistency, and also building a CI/CD Pipeline for streamlining your deployments if this is not a test environment or a PoC.
Hope this helps!

VSTS use on premise deployment agent

I ran out of release/build minutes on VSTS, therefore I configured an on premise agent to run my builds. This is working fine, however I cannot select that agent to be used for deploying my releases.
I tried to follow the following tutorial, however it seems like it is a bit old:
http://vsts-deploy-guide.readthedocs.io/en/latest/
Does anyone have experience setting up on premise agents to do the deployment?
Refer to these steps:
Open release definition
Select Environments tab
Click Run on agent
Change Deployment queue in right panel.

Executing different set of MSBuild tasks for each user?

In our development environment each developer has their own dev server. Often times they do not actually develop on that server but develop from their local machine, deploy to their dev server, and then attach with the remote debugger to do debugging.
My question is; how can I use MSBuild to execute a different set of tasks for each user?
I want to enable each user to define their own build process with MSBuild tasks but I don't want that to necessarily affect the other developers. I also want a default set of tasks to execute if a given user explicitly defined their own process.
Example:
SomeProj.csproj
Default MS Build process is to copy to test server or staging server
Custom process for Steve is to copy to Steve's dev server
Custom process for Eric is to copy to Eric's dev server
You could use the project user file (*.suo / *.user) to do some 'poor mans dependency injection'.
looks like this guy did something similar
Yeah, I've done this before. Try trick is to key off $(USERNAME) in your msbuild script. If you haven't tried editing msbuild scripts before, you've got a lot of learning to do.

Resources