Publish Binaries in TFS 2017 MS BUILD - tfs

These are my MS build arguments
/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\CC
What should I use to Publish only binaries using Publish artifacts. I am getting code files only.

If you just want to output the files without zip, then you can try below ways:
Specify the argument OutputPath only (without specify the package
related arguments):
e.g:
/p:OutputPath="$(build.artifactstagingdirectory)\cc"
You can also output the target files to a shared path (UNC path):
e.g:
/p:OutputPath="\\myshare\DirA\0313"
Then use Copy and Publish build Artifacts task to publish the
files. Alternatively you can add a Copy Files task to copy the
files from OutputPath to a Temp folder, then use Publish
build Artifacts task to publish the files from Temp folder.
Reference the first screenshot.
Another workaround is using the publish profile:
Create a Folder publish profile, you can chose a shared folder
to publish. (Refer to this link to create the publish profile)
Add below MSBuild arguments in VS build or MSbuild task:
/p:DeployOnBuild=true /p:PublishProfile=YourPublishProfile
Check the published artifacts.
Reference the second screenshot:

Related

How to copy nupkg from build process to drop folder

TL/DR: In a release step, how do I find a .nupkg file that was definitely created in a build process and copy it to a drop folder for use in a release task?
Using TFS 2018, I am trying to copy a .nupkg file created in a prior Build task to the drop folder.
...In the Build Process...
From the log, I know that the file was created.
Successfully created package
'C:\agent_work\9\a\StaticHelpers.1.0.0.nupkg'.
What I am trying to figure out is how I can find this file and copy it to the drop folder. Using Build Variables for inspiration, I have tried the following. At first, I thought it was successful because of what the log said.
Source Folder: $(Agent.BuildDirectory)
Contents: *\*.nupkg
Target Folder: drop
Result:
found 1 files Copying C:\agent_work\9\a\StaticHelpers.1.0.0.nupkg to
drop\a\StaticHelpers.1.0.0.nupkg
All that means is that I can create a release process that takes that file and copies it in a copy release step, right?
...In the Release Process...
Not right. There is nothing in the drop folder when I created a copy file release task and tried to select the nuget package that was definitely created in the build. What I need to do is take that *.nupkg file created during the Build process and copy it to a network share.
So I tried to hard-code the folder based on what I copied from the build log.
Source Folder: drop\a
The release failed, showing this in the log:
[error]Unhandled: Not found SourceFolder: C:\agent_work\r4\a\drop
Either I am copying the file to the wrong location or I am reading from the wrong location. What folders do I need to use so that I can see the *.nupkg file in my release task?
In your build process, don't use a Copy Files task, use a Publish Artifacts task. That will publish an artifact "attached" to the build that a release will automatically pick up during deployment.

How to publish binaries TFS 2017

Whenever i do the publish its having the CS and Solution files as well.
I tried too many things but all in vain
enter image description here
These are my MS build arguments
/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\CC
You're specifying a package location in your MSBuild arguments: /p:PackageLocation="$(build.artifactstagingdirectory)\CC. That's the path you want to publish as an artifact if all you want is the packaged binaries.
The path you're currently specifying, $(agent.builddirectory)\s\Main\State is the location used by the build agent to synchronize source code, so of course you're capturing source code when you publish that as an artifact.

Copy the Setup file to a folder named with version number in TFS

We are using TFS build and when I built the project in TFS build, it also creates a setup file.
For example, my application version is V1.2.3 (its from assembly.cs) the location of the setup file is C:\myproject\setup\setup.exe
Well I want to copy this setup exe into the following folder
C:\products\producta\ V1.2.3
So I just need to get version number to create a folder named "V1.2.3". For copying and creeating, i can make a batch file but i do not know how to get version number. TFS has some variables for example Build.SourceVersion
but these variables do not give me the product's version number.
How I can do this thing?
You have to write a script to do this.
1) Powershell script to read the build number from assemblyInfo.cs
$myAssemblyVersion = major.minor.patch -> Read from assembyInfo.cs
$versionWithBuildId = '{0}.{1}' -f $myAssemblyVersion, $Env:BUILD_BUILDID
2) Update the TFS internal build number from current build
Write-Verbose -verbose "##vso[build.updatebuildnumber]$versionWithBuildId"
After that you can use the "Copy Files" or "Publish Artifact" step.
With "Copy Files"
Target Folder = "C:\products\producta\$(Build.BuildNumber)"
With "Publish Artifact"
Artifact Name = "$(Build.BuildNumber)"
Path = "C:\products\producta"

TFS 2015 Copy and Publish Build Artifacts without subdirectories

I have created a Copy and Publish Build Artifacts build step in TFS 2015 with the following parameters:
Copy Root: $(build.sourcesdirectory)\bin\Installers
Contents: **
The according to https://www.visualstudio.com/pl-pl/docs/build/steps/utility/copy-and-publish-build-artifacts it should not copy the subdirecttories but unfortunately it does it!
How to copy and publish build artifacts whitout subfolders?
Please add the suffix of the files after **, then you won't get the subdirectories. For example, in the following setting, you'll only get .txt and .dll files under $(build.sourcesdirectory)\bin\Installers, but you won't get .txt and .dll files in any sub folders under $(build.sourcesdirectory)\bin\Installers:
You can use **.* instead of **.

MSBuild not copying files with PublishProfile

I have a Visual Studio 2013 solution with the full Orchard source code. When I use "Publish..." on the "Orchard.Web" project in Visual Studio, it correctly publishes the site to the File System destination I've configured into the .PubXml file that I used.
However, if I build this site using Jenkins, the files do not get copied to the destination. I've created a separate PubXml file that is used by Jenkins.
In my Jenkins job, I have two Build steps of interest. The first uses the src\Orchard.sln file with a command line argument of /p:Configuration=Release. This runs correctly, and builds the entire solution.
The second Build step, immediately after, uses the Build File of src\Orchard.Web\Orchard.Web.csproj and these command line arguments:
/p:DeployOnBuild=true
/p:PublishProfile="D:\workspace\Site\trunk\src\Orchard.Web\Properties\PublishProfiles\Jenkins.pubxml"
/p:VisualStudioVersion=12.0
/p:Configuration=Release
/p:Platform=AnyCPU
/v:minimal
/nologo
/p:WarningLevel=1
With this, the build and deploy seems to work - but doesn't. Here are some lines from the build output:
Copying all files to temporary location below for package/publish:
obj\Release\Package\PackageTmp.
Auto ConnectionString Transformed obj\Release\Package\PackageTmp\Shapes\Scripts\Web.config into obj\Release\CSAutoParameterize\transformed\Shapes\Scripts\Web.config.
(... about 200 more "Auto ConnectionString..." lines...)
Finished: SUCCESS
No where does it actually copy the files to the destination defined in the PUBXML file.
In contrast, in Visual Studio, the output looks similar, but transforms only 4 config files and includes lots of "Publishing folder x" lines:
(...)
Transformed Modules\SH.GoogleAnalytics\web.config using ....
Copying all files to temporary location below for package/publish:
obj\Release\Package\PackageTmp.
Publishing folder /...
Publishing folder bin...
(etc.)
(I have installed the latest Windows Azure SDK for .NET on the Jenkins server.)
I have the same trouble,that work for me:
/t:Rebuild
/p:DeployOnBuild=true
/p:PublishProfile=Jenkins_Publish
/p:Configuration=Release
do not use /p:VisualStudioVersion=xxx
This is kind of old, but I actually just set up Orchard to be able to get built via command line and MSBuild. Here is what I did:
/p:VisualStudioVersion=12.0;PublishProfile="example-profile";DeployProjA=true;FrameworkPathOverride="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v4.5";Configuration=Release;PublishProfileRootFolder=c:\Workspace\src\Orchard.Web\Properties\PublishProfiles;Password=ExamplePass
Since you are using Orchard you want to make sure that only the Orchard.Web project gets published so do not use DeployOnBuild=true. This will attempt to deploy every web project in the solution, which is a lot for Orchard. Instead follow the guidelines here to see how to deploy only the web project: http://sedodream.com/2013/03/06/HowToPublishOneWebProjectFromASolution.aspx

Resources