No packages found with specified pattern - azure

I am using Deploy azure app service to slot build step in Team Services, I want to be able to build my solution with PackageAsSingleFile set to False. However when I try to release the package with path to the artifact created I get "No packages found with specified pattern".
Do I need to create two artifacts, one as zip file and one as a package of files to be able to do what I want? I have tried different path to folders, but I get same error no matter.

Refer to these steps:
NuGet Installer task to restore package
Visual Studio Build task (Solution: ***.sln; Visual Studio Version: Visual Studio 2015; MSBuild Arguments: /p:DeployOnBuild=True /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem /p:DeleteExistingFiles=True /p:publishUrl="$(build.artifactstagingdirectory)\"; Platform: $(BuildPlatform); Configuration: $(BuildConfiguration))
Publish Build Artifacts (Path to Publish: $(build.artifactstagingdirectory); Artifact Name: drop; Artifact Type: Server)
Edit/create Release definition
Link artifact to previous build
Azure App Service Deploy (Package or Folder: $(System.DefaultWorkingDirectory)/**/drop)
Uncheck Publish using Web Deploy option

I used zip file, and Azure App Services Deploy task can be execute successfully.
For the related build definition, you can use below tasks:
Copy Files task:
Source Folder: $(Build.SourcesDirectory).
Contents: the project you want to deploy to Azure, such as ASPNETCoreProj\**.
Target Folder: $(Build.ArtifactStagingDirectory).
Archive Files task:
Root folder (or file) to archive: $(Build.ArtifactStagingDirectory).
Archive type: zip.
Archive file to create: $(Build.ArtifactStagingDirectory)/project.zip.
Publish Build Artifacts task:
Path to Publish: $(Build.ArtifactStagingDirectory).
Artifact Name: drop.
In the release definition, you can specify Package or folder as $(System.DefaultWorkingDirectory)\**\*.zip in Azure App Services Deploy task.

Related

Azure CI pipeline ignored my botdetect.xml file

I am using Azure CI pipeline and using the .NetCore build tasks template, today I noticed that the file botdetect.xml in my source control, and after project passes from CI/CD pipeline, specific .xml
dotnet publish command publish the output of your .NET build, you need to make sure the botdetect.xml file exists in your build output, then it can be published to $(Build.ArtifactStagingDirectory) by running dotnet publish --output $(Build.ArtifactStagingDirectory), and publish the artifact by using Publish artifact task.
You could check your .csproj file to see whether the .xml file has been set to "Always Copy To Output Directory", it seems like:
<Compile Include="botdetect.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Compile>

Trigger a specific project inside a repository when creating a build in Azure build pipeline

I have one repository with 3 branches dev, test and prod. I have a Visual Studio solution with 3 projects in it. One Angular, a worker service and ASP.NET web api project. So that whole solution in one repository.
I have pushed everything to dev branch. So when creating the build pipeline I chose ASP.NET core and then on writing the build yaml, in the trigger I specified Dev branch
trigger : - dev
But how can I specify which project to build among the 3 project in that repository to build? My plan is to build the ASP.NET core web api to build.
Also I need another build for the angular as well..
This will be in your build task:
steps:
- task: DotNetCoreCLI#2
displayName: Build
inputs:
command: build
projects: '**/*.csproj' # Update this to match your need
arguments: '--configuration $(buildConfiguration)'
The project path will be different for your various projects

Azure deployment from Azure DevOps failing to find zip package

I am setting up a build and release pipeline for our Azure mobile app using Azure DevOps. I have completed the build and all works fine. I have a build task defined that creates the required zip file for deploying to Azure and this succeeds and the zip file is created at the root of the folder. But the deployment fails stating that the zip file cannot be found.
Here is my build task that creates the zip file.
And here is the output from the build step showing that it has successfully created the zip file.
But the deployment fails as it can't find the zip file.
You need to publish the .zip file from your build using the Publish Build Artifacts task. That will make it available as an artifact to be linked into a release definition to be deployed.

ASP.Net Core solution publishing wrong project

I created a new ASP.Net core project and set it up in source control which publishes to Azure when I do a check-in. I was able to get everything setup correctly and it was working fine.
However, I then added a class library project to the solution and now instead of publishing my website project the MSBuild task is attempting to publish my class library which of course fails.
The line in the deployment command is:
"%MSBUILD_PATH%" "%DEPLOYMENT_SOURCE%\MySolution.sln" /nologo /verbosity:m /p:deployOnBuild=True;AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release;UseSharedCompilation=false;publishUrl="%DEPLOYMENT_TEMP%"
And when that runs it first builds the models project which is fine:
D:\Program Files (x86)\dotnet\dotnet.exe build "D:\home\site\repository\MySolution.Models" --configuration Release --no-dependencies
But then it attempts to publish that project as well:
D:\Program Files (x86)\dotnet\dotnet.exe publish "D:\home\site\repository\MySolution.Models" --output "D:\local\Temp\PublishTemp\MySolution.Models71" --configuration Release --no-build
D:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Publishing.targets(149,5): error : Can not find runtime target for framework '.NETStandard,Version=v1.6' compatible with one of the target runtimes: 'win8-x86, win7-x86'. Possible causes: [D:\home\site\repository\MySolution.Models\MySolution.Models.xproj]
Which is the wrong project (it should be the web project). I can't seem to find any files that contain the settings for this or the setting in the solution file itself.
What do I need to do for this to publish the correct project?
I was able to solve this by doing it in two steps.
First remove the deployOnBuild=True and the publishUrl=[snip] from the msbuild command. This means this step will build the project but doesn't do any publishing.
Next add a new step that does the publish.
To do this I first created a new variable to hold the location of the dotnet.exe:
IF DEFINED DOTNET_PATH goto DotNetPathDefined
SET DOTNET_PATH=%ProgramFiles(x86)%\dotnet\dotnet.exe
:DotNetPathDefined
Then add the following to do the publish of the web project:
call :ExecuteCmd "%DOTNET_PATH%" publish "%DEPLOYMENT_SOURCE%\MySolution.Web" --framework netcoreapp1.0 --output "%DEPLOYMENT_TEMP%" --configuration Release --no-build
IF !ERRORLEVEL! NEQ 0 goto error
This then publishes all the files to the deployment temp folder which then get deployed using the KuduSync step.

How can I have teamcity run a .bat file on each successful build?

I have a teamcity (4.something) install that creates .wsp file for deployment to sharepoint. Currently I have to copy the wsp out of the build artifacts directory and into a little deploy folder I have created. In the folder I run a .bat that deploys the new .wsp to our test server.
What steps can I take to automate this?
Either copy the .bat into the artifacts folder and update the paths etc or copy from the artifacts folder into the 'deploy' folder and run the .bat from there.
I am a neophyte when it comes to the intricacies (or basics!) of MSBuild and the like... so hand holding is appreciated!
In more recent versions of TeamCity...
In the build definition you can identify artifacts which can be copied/zipped. Artifacts can then be downloaded manually or referenced from another build (Artifact Dependency).
You can setup a 'build configuration' to do your deployment directly from artifacts produced by your ci build.
Create a build to do your deployment
Build Step
Run: Executable with parameters
Command executable: .bat file (make sure it as part of the ci build artifacts generated)
Command parameters: whatever parameters your patch files needs
Dependencies
Add New Artifact dependency
Depend on: select the ci build you want to deploy
GetArtifacts from: Last successful build
Artifact rules: +:**/*.*
So, given artifacts (like your batch file) are in the CI build... You now have a 'deploy' build. When you run it (manually or setup a Build Trigger) it will copy all the CI build artifacts to it's working directory (Artifact Dependency) and then run your batch file to do the deployment.
Pretty slick.
note: just make sure that the account running the TeamCity BuildAgent has permissions to do all the deployment stuff.
Hope this helps somebody as it took me a while to sort this out ;)
I've done this by creating a nant task, and then having TeamCity execute the nant task. It's more of a pain than it should be. You should be able to do the same as a post-build event with MSBuild.

Resources