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
Related
My solution consists of multiple projects, I'm trying to build a single project among that solution using MSBuild and trying to generate an .exe file and publish an artifact in Azure DevOps. I tried to build the specific project using MSBuild task on Azure pipelines but it was throwing and it is throwing an error 'MSBuild.exe' exited with code '1'.
I've tried using My hosted agent and used windows command prompt for building the specific project but unable to generate an artifact with the .exe file .
Is there any way to build a specific project in a solution using MSBuild task or from the Command Prompt using Azure Hosted agent in Azure DevOps.
In the project textbox you have to select a certain .csproj file to build or you can supply a pattern, like **/*.csproj for all csproj files in all sub folders.
I have a aps.net 3.5 solution stored in TFS. Usally I choose "publish" in VS2015 to get only the needed files into a target directory. That I use to create a package for deployment to a webserver.
Now I want to use the buildserver to create that package. My problem is, I can build the solution with a "Visual Studio Build"-Step, but I can't tell which files to copy by a "Copy Files"-Step.
I thought to call msbuild.exe using powershell but had no success setting a target directory for an existing profile. With /p:OutDir it copied the wrong files.
A "IIS Deployment"-Step does no simple filesystem copies, as far as I can see.
So how can I do what VS2015 does by "publish" with target filesystem on the Build-Server using dynamic output directories.
Refer to these steps:
Click new to create a new build definition
Select ASP.NET build template
Select Visual Studio Build task and choose corresponding version of VS in Visual Studio Version input box
(optional) Remove Visual Studio Test and Publish symbols path tasks.
With ASP.NET build template, you can find that, there is the MSBuild Arguments like this, which is used to create web deployment package and put it to artifact directory:
/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\"
I have a task on a Visual Studio Team Services configured as follows:
The solution contains an ASP.NET Web Forms application. The task compiles the solution but unfortunately compilation errors on .aspx files are ignored. Is there any way to check for errors on .aspx pages on build?
TL;DR Just set the MSBuild property PrecompileBeforePublish to 'true'
Long version:
The preferred option is to create a web package (a .zip file), that you could then feed to VSTS Build/Release tasks that would deploy it on Azure App Service or IIS.
In order to create a web package trigger the Web Publishing Pipeline during build by passing these additional arguments to MSBuild (on the Visual Studio Build task):
/p:DeployOnBuild=true /p:WebPublishMethod=Package
/p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true
/p:PackageLocation="$(build.artifactstagingdirectory)\\"
/p:PrecompileBeforePublish=true
This would either precompile the .aspx file as well as copying the .zip file locally on the artifact staging directory on the agent machine. Use the $(build.artifactstagingdirectory) variable to refer to this directory in subsequent tasks in order to publish this artifact.
As already mentioned by Luca, PrecompileBeforePublish does the trick.
I decided to post another answer because the MSBuild arguments he gave as an example did not work for me. I used the following arguments:
/t:Package
/p:PackageLocation="$(build.artifactstagingdirectory)\website.zip"
/p:OutputPath=.\bin
/p:Configuration=$(BuildConfiguration)
/p:PrecompileBeforePublish=true
Build is now detecting errors in the .aspx pages such as missing resources:
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.
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