Clearing Asp.net Bin folder before deploying code using TeamCity - asp.net

I am a newbie to TeamCity and Octopus Deploy.
My project has many branches that uses different version of 3rd party dlls. The problem i am facing is when i am switching branches in TeamCity and build the code it deploys (using Octopus Deploy) the code successfully but it doesn't clear the target folder.
Like the Bin folder holds all the dll required by the project so when i switch branches and build using TeamCity and deployed using Octopus Deploy the previous dll are not removed and the application shows following error due to existence of same class in multiple dlls
The call is ambiguous between the following methods or properties
How can i fix this issue?

There is a couple of ways to do this. It really depends on how you are versioning and deploying your code from TeamCity to Octopus. If you are using NuGet pacakges and providing a version for each package, then having Octopus trigger a deployment based on the new package version, you will have a new directory for each deployment, and you won't have this problem at all. That being said, here are a couple of ways to fix this in your current workflow.
Use a Powershell script as the first step in your deployment, and have that script clean the deployment directory.
Use a "Custom Installation Directory" and set the "Purge this directory before installation" flag.
To enable the "Custom Installation Directory," click on "Enable features," on the bottom of your deployment step, and check "Custom installation directory"
Then configure your directory path and check the "Purge this directory before installation" option.

Related

ASP.NET Website CI using Azure Dev Ops Pipeline

I've a legacy project, which is a ASP.net Website project(not having .csproj file). It holding .aspx files and packages.config for nuget and other dependencies. Now I want to deploy it to Azure app service by automation with CI/CD in Azure Dev Ops pipeline.
I can't find anything which is suitable for all tasks I need for CI.
Here I don't have .csproj, so I build it using packages.config
Task I tried
Update .sln to .config, because I have more than one website in single solution.
Update Nuget Restore task with install, it doesn't work with restore
And while queue, this pipeline got failed on Build task
Error it thrown
Visual Studio Build task cannot build packages.config file, this task uses MSBuild to build. In Solution argument, only .sln file or .*proj file can be specified.
Solution: Required) If you want to build a single solution, click the
... button and select the solution.
If you want to build multiple solutions, specify search criteria. You
can use a single-folder wildcard (*) and recursive wildcards (**).
For example, **.sln searches for all .sln files in all
subdirectories.
You can also build MSBuild project (.*proj) files. If you are building
a customized MSBuild project file, we recommend you use the MSBuild
task instead of the Visual Studio Build task.
Default value: ***.sln

Core files from restored package is missing in resulted Artifact in Azure DevOps PipeLine

In the task "Visual Studio Build" in my Azure DevOps pipeline, I found it processes one of my third party package (called Umbraco)in a stage called "Publish Pipeline Deploy phase Stage PipelineMsdeploySpecificTransformPhase", which runs after "PipelinePreDeployCopyAllFilesToOneFolder". Therefore, the final Artifact does not include these Umbraco core files.
I am wondering what is this "PipelineMsdeploySpecificTransformPhase", why VS Build task copies Umbraco package at this staging? Is there a way to control it?
Below is the task log - web file system publish is before the Umbraco files are copied over.
Below is my Visual Studio Build task setup - I am trying to publish it as files rather than zip packages
I am new to StackOverflow, hope my question makes sense. Thanks in advance.

How to deploy ASP.NET MVC application with devexpress components to Azure websites

Is there a way to deploy asp net application with dexexpress components other than using virtual machine with installed libs on it?
I want to deploy it to azure websites but get an error that .dll are missing (dont get that error during debugging on localhost where devexpress installed).
Be sure, that you marked the referenced assemblies that you want to publish on the vm as "copy local = true". You can find that option in the properties of a reference.
The output folder of your web app will be automatically copied over to azure websites. For more information how web pages are packaged have a look How to: Create a Web Deployment Package in Visual Studio
You can try one of these options:
Find a NuGet package which includes the dll's you need. I don't know which components you use but NuGet contains a lot of packages -> https://www.nuget.org/packages?q=devexpress
Include the dll's you need in a 3thPartyLib in your project and then reference these assemblies (with copy local = true) from your project.
Be sure to include the license file in your deployment.

Precompiled in asp.net application not required

I have a website project and some other projects that are tied up via a solution file. When I build the solution using visual studio, it does not create precompiled version of website but using msbuild to build the solution creates precompiled version.
We don't use precompiled code to deploy on servers so this version is not required in our process.
And this takes a lot of time to get created.
So how can I avoid creation of pre compiled version? Is there any switch or task that I can use in msbuild scripts to build the solution.
I need msbuild to simply build the solution.
currently the command that I am using is:
msbuild "ABC.sln"
MSBuild on the command line features a /t switch, which allows you to define build targets. You would use this switch to target all the other subfolders in the solution, leaving the website untouched.
MSBuild Command Line arguments on MSDN

Same MSBuild file, different results on local machine and CCNet

Background
I am utilizing the following:
VS 2012
.NET 4.5 apps including an MVC4 app, a C# Domain app, and NUnit projects.
A custom MSBuild File
CruiseControl.NET running on a build server
I have the following build targets:
Clean: deletes the buildartifacts directory
Init: creates a blank buildartifacts directory
Compile: compiles the solution
Test: runs NUnit Tests
Package: creates a ZIP package for deployment
Deploy: Deploys package to a remote IIS Server
Problem
When I run the build from my local machine, it packages and deploys perfectly.
When CCNet runs the same build target, the files appear to be deployed
Attempted Resolutions / Potential Leads
I have run the same target in PowerShell from both machines and have seen no errors or warnings on either.
Because I tell CCNEt to override the framework to point it to the .NET 4.5 files I've copied to the build server, I made my local machine point to the same files when running MSBuild but my local build still worked and deployed.
In Visual Studio, I have ensured that all content files are marked with a Build Action of "Content" and a Copy to Output setting of "Copy Always".
The Code
Available in a gist at https://gist.github.com/53ef2a63931d190593f6
(file has been scrubbed, app name & credentials replaced, etc.)
It turns out, this was a completely unrelated issue.
After doing a diff of both build logs, I noticed that the build server working copy contained old files that no longer existed. This led me to discover that the issue ended up being that the repository wasn't being updated.
CCNet was receiving a subversion error that wasn't registering as an error
As a result, I was never getting the latest version of the repository, and so all files were broken.
The error is related to this StackOverflow question, regarding a sqlite error when attempt to use tortoisesvn to update. The solution in my case was to simply delete the build server's working copy, recreate the folder, and perform an svn checkout.

Resources