When building a Service Fabric application on a build server, is there a way to get a deployment package built with .sfproj / nuget combination?
Digging around found that there's a .sfpkg option, but it is not clear how to build that using MSBuild.
The possible duplicate is showing how it package a service fabric application from a command line. I was after achieving the same when building a solution in release mode. This section can be added to the .sfproj file to achieve the goal:
<Target Name="ReleaseAfterBuild" AfterTargets="AfterBuild" Condition=" '$(Configuration)' == 'Release' ">
<MSBuild Projects="$(ProjectPath)" Targets="Package" />
</Target>
Related
I am deploying BizTalk applications using BizTalk deployment project and azureDevOPS.
I need to add a reference to the another application. BTDF used to have "AppsToReference", how to achieve the same thing using BizTalk Deployment Project.
<ItemGroup>
<AppsToReference Include=" Company.Application.SharedObjects"/>
<AppsToReference Include="BizTalk EDI Application"/>
</ItemGroup>
I have a build definition with the following build steps in the following order:
NuGet Installer
Npm
Gulp
Visual Studio Build
Azure Web App Deployment
In step 3, Gulp generates a dist folder in my application root. The dist folder contains some subfolders and files. The subfolders themselves can contain other subfolders and files.
In step 4, the Visual Studio Build step creates a <ProjectName>.zip zip file when completed.
The Azure Web App Deployment step then deploys that zip file to my Azure Web App.
How do I include the dist folder in <ProjectName>.zip?
I tried doing two Azure Web App Deployments deploying one zip file at a time in the same build definition but the second Azure Web App Deployment build step wipes whatever was deployed by the first one. Is there a way to tell the second Azure Web App Deployment step to "append" to whatever was deployed by the first Azure Web App Deployment step?
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" />
<Import Project="..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
...
...
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
...
...
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target> -->
<PropertyGroup>
<CopyAllFilesToSingleFolderForPackageDependsOn>
CustomCollectFiles;
$(CopyAllFilesToSingleFolderForPackageDependsOn);
</CopyAllFilesToSingleFolderForPackageDependsOn>
<CopyAllFilesToSingleFolderForMsdeployDependsOn>
CustomCollectFiles;
$(CopyAllFilesToSingleFolderForPackageDependsOn);
</CopyAllFilesToSingleFolderForMsdeployDependsOn>
</PropertyGroup>
<Target Name="CustomCollectFiles">
<ItemGroup>
<_CustomFiles Include="dist\**\*" />
<FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
<DestinationRelativePath>dist\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
</FilesForPackagingFromProject>
</ItemGroup>
</Target>
</Project>
The property CopyAllFilesToSingleFolderForPackageDependsOn must come after the import <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
dist\**\* means take the dist folder that is directly underneath web application root
dist\%(RecursiveDir)%(Filename)%(Extension) means place the dist folder directly underneath the web application root inside of the package
Example package path:
C:\_publish\BuildAgentDemo.zip\Content\C_C\Repos\BuildAgentDemoTest1\BuildAgentDemo\obj\Release\Package\PackageTmp\dist
BuildAgentDemo.zip is one of the artifacts created by the Web Deploy Package publish profile
PackageTmp is your web application root
dist is where your custom folders and files will end up
You can add a custom target in your project file to include the files generated by Gulp. Refer to this question for details: How do you include additional files using VS2010 web deployment packages?
And another way to get the Gulp folder published is enabling the FTP deployment of your Azure Web App. And then you can add a FTP Uploader task after "Azure Web App Deployment" task. Use "Azure Web App Deployment" task to deploy the package generated by VS Build and use "FTP Uploader" task to upload the "dist" folder into Azure Web App. Note: Make sure you unchecked the "Delete old Files" option of the FTP Uploader task.
How to create a deployment package for Service Fabric that includes all artifacts necessary to run the designed workflows at run-time?
Another option is to package a service fabric application by building a solution in release mode (for example). This section can be added to the .sfproj file to achieve the goal:
<Target Name="ReleaseAfterBuild" AfterTargets="AfterBuild" Condition=" '$(Configuration)' == 'Release' ">
<MSBuild Projects="$(ProjectPath)" Targets="Package" />
</Target>
To create a Service Fabric application package you need to run the "Package" target on the sfproj file.
msbuild app.sfproj /t:Package
This will create a "pkg" directory next to the sfproj file with all the necessary files.
Given I have a post build process that generates files in \bin\out how can I use a MSBuild targets file to state that all files (recursively) in that directory should be published during web deploy?
Let's split this in two parts:
First, build the web project:
<Target Name="BuildWeb">
<MSBuild Projects="WebExtranet\WebExtranet.csproj"
Properties="Configuration=$(Environment);DeployOnBuild=True;CreatePackageOnPublish=True;BaseIntermediateOutputPath=..\$(DistDir)\Web\" />
</Target>
Then use this to publish to the local IIS (you might need to adjust the msdeploy command to suit your needs)
<Target Name="DeployWeb">
<ItemGroup>
<PackageSourceDir Include='$(DistDir)\Web\$(Environment)\Package\WebExtranet.zip' />
</ItemGroup>
<Message Text="Package path: %(PackageSourceDir.FullPath)" />
<Exec Command=""c:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync -allowUntrusted -source:package="%(PackageSourceDir.FullPath)" -setParam:'IIS Web Application Name'='My Web App' -dest:auto"/>
</Target>
Common pitfalls:
The msbuild version is important. I'm using V3.
You have to have the web application already created on IIS. Only need to do it once.
Note that the $(Environment) variable is the build configuration. I have several, but run the first target and check the folder structure created. Then adjust the script.
currently I'm developing in eclipse 3.5 in different project web applications for tomcat 6.0.24.
For each of this project I have written a ant build file to generate the war file to deploy the project to the tomcat container.
So I have to run for each project the ant build file (a lot of clicks, and a waste of time).
Question: Is there a possibility to run all needed ant build files with a single click, from a single project or whatever?
#thelost
thank you very much for your hint, you brought me on the right way,
I solved the problem:
<target name="build">
<ant antfile="jar-build.xml" target="GEN-JAR_FILES" />
<ant antfile="war-service01.xml" target="SVC01-WAR"/>
<ant antfile="war-service02.xml" target="SVC02-WAR"/>
</target>
best regards, Alex
Sure. E.g., you could create a master build file and use the Exec task.