The new TFS2015 Build system is very powerful and easy to use.
but there are still no tasks for git integration and we are forced to use batch / Power Shell scripts.
commit / push
when a git is cloned by the build it creates a detached head (temporary branch)
do this (case sensitive):
git commit "<files>" -m "comment"
git branch -a // show all branches optional
git rebase HEAD <branch name>
git push origin <branch name>
**
make sure the build agent user has "Exempt from policy enforcement" set
to allow otherwise the push will fail if branch policies exist.
Warning
I
have noticed that using pull request with a build policy and the build
performs updates to the repository causes the pull request to not
function correctly as rebase also pushes the pull request.
branch polices
Although written, for all new users to Git, Visual studio will not let you create a Pull request
(available since VS2015.1) from the same branch locally to the same branch remotely.
the ideal way is to use git flow and create pull request from develop to master
Showing posts with label Builds. Show all posts
Showing posts with label Builds. Show all posts
Saturday, April 23, 2016
Wednesday, January 6, 2016
Running old XAML build templates on TFS 2015 build server
Recently i arrived to help a client in upgrading their TFS2012 to TFS2015 Update 1.
the upgrade passed successfully without any issues.
however when we tried to run the builds we often got an error the template could not be loaded.
So first thing i did was to verify all the custom build assemblies were upgraded and don't contain "microsoft.teamfoundation.dll" as this assembly is not included since TFS2013 (merged to microsoft.Teamfoundation.Client). sadly this did not help.
after long try and error (google was no help here :(), i found this to be a reference written in the XAML it self.
i opened the XAML in Notepad and found,
there is a section called "TextExpressions.ReferancesForImplementation" there i found
<AssemblyReference>Microsoft.TeamFoundation</AssemblyReference>
removing this line fixed the problem and the template was able to load
hope this will help you also...
the upgrade passed successfully without any issues.
however when we tried to run the builds we often got an error the template could not be loaded.
So first thing i did was to verify all the custom build assemblies were upgraded and don't contain "microsoft.teamfoundation.dll" as this assembly is not included since TFS2013 (merged to microsoft.Teamfoundation.Client). sadly this did not help.
after long try and error (google was no help here :(), i found this to be a reference written in the XAML it self.
i opened the XAML in Notepad and found,
there is a section called "TextExpressions.ReferancesForImplementation" there i found
<AssemblyReference>Microsoft.TeamFoundation</AssemblyReference>
removing this line fixed the problem and the template was able to load
hope this will help you also...
Monday, December 29, 2014
TFS2013 Web.Config Transformation in Build
Hi
i have been looking around how to create web.config transformation when using tfs build.
there are 3 options:
/p: TransformConfigFiles=true
just don't forge, if you are using TFS2013 with old build templates (2010/2012) you will also need to add "/p:VisualStudioVersion=12.0"
i have been looking around how to create web.config transformation when using tfs build.
there are 3 options:
- Use publish profile - this is done by creating a publish profile (right click on the project and select publish), then add to the build definition, "MSBuild Arguments"
- Add "xmlTransform" task to the csproj - open the csproj file for edit (Unload and edit) and add right before the end
<Target Name="TransformConfigFiles" AfterTargets="AfterBuild" Condition="'$(TransformConfigFiles)'=='true'"> <ItemGroup> <DeleteAfterBuild Include="$(WebProjectOutputDir)Web.*.config" /> </ItemGroup> <TransformXml Source="Web.config" Transform="$(ProjectConfigTransformFileName)" Destination="$(WebProjectOutputDir)Web.config" /> <Delete Files="@(DeleteAfterBuild)" /> </Target>in order to control this, you need to add to the build definition, "MSBuild Arguments"
/p: TransformConfigFiles=true
- Force MSBuild to run Config transformation - this is done by add to the build definition, "MSBuild Arguments"
just don't forge, if you are using TFS2013 with old build templates (2010/2012) you will also need to add "/p:VisualStudioVersion=12.0"
Saturday, April 13, 2013
Web Deployment in TFS2012 - Part 2
In the previouse post i have shown how to publish.
this we publish the whole site, but what if i need external resources or exclude some config files?
so i looked around good people and here is what i found (also validated):
Adding to the Deployment
<PropertyGroup>
<CopyAllFilesToSingleFolderForPackageDependsOn>
CustomCollectFiles;
$(CopyAllFilesToSingleFolderForPackageDependsOn);
</CopyAllFilesToSingleFolderForPackageDependsOn>
</PropertyGroup>
<Target Name="CustomCollectFiles">
<ItemGroup>
<_CustomFiles Include="D:\Dev\W2012TFS2012Prd\DefaultCollection\Test\MySites\MvcApplication\Properties\PublishProfiles\**\*" />
<FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
<DestinationRelativePath>Extra Files\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
</FilesForPackagingFromProject>
</ItemGroup>
</Target>
Exclude From Deployment
<PropertyGroup>
this we publish the whole site, but what if i need external resources or exclude some config files?
so i looked around good people and here is what i found (also validated):
Adding to the Deployment
<PropertyGroup>
<CopyAllFilesToSingleFolderForPackageDependsOn>
CustomCollectFiles;
$(CopyAllFilesToSingleFolderForPackageDependsOn);
</CopyAllFilesToSingleFolderForPackageDependsOn>
</PropertyGroup>
<Target Name="CustomCollectFiles">
<ItemGroup>
<_CustomFiles Include="D:\Dev\W2012TFS2012Prd\DefaultCollection\Test\MySites\MvcApplication\Properties\PublishProfiles\**\*" />
<FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
<DestinationRelativePath>Extra Files\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
</FilesForPackagingFromProject>
</ItemGroup>
</Target>
Exclude From Deployment
<PropertyGroup>
<ExcludeFilesFromPackageDependsOn>
$(ExcludeFilesFromPackageDependsOn);
_ExcludeAzureDlls
</ExcludeFilesFromPackageDependsOn>
</PropertyGroup>
<Target
Name="_ExcludeAzureDlls">
<ItemGroup>
<AzureFiles
Include="@(FilesForPackagingFromProject)"
Exclude="@(FilesForPackagingFromProjectWithNoAzure)" />
<ExcludeFromPackageFiles
Include="@(AzureFiles)">
<FromTarget>_ExcludeAzureEnvironmentDlls</FromTarget>
</ExcludeFromPackageFiles>
</ItemGroup>
</Target>
taken from : http://pastebin.com/6BFehAG3
here is a MSDN FAQ about Web Deployment http://msdn.microsoft.com/en-us/library/ee942158.aspx it also helped abit
Web Deployement in TFS2012
Web Deployment in VS2012 relies on the new Publish framework and the use of publish profiles.
using these profile gives us the ability to create different publishing for different environments.
all that is nice and well and work splendid with the VS2012, but what with my Builds?
We have 2 options:
Also for File System Publish update publish profile like this, because of a bug in the build:
using these profile gives us the ability to create different publishing for different environments.
all that is nice and well and work splendid with the VS2012, but what with my Builds?
We have 2 options:
- Add to Build Definition, Process->Advanced->MSBuild Arguments "/p:DeployOnBuild=true /p:PublishProfile=<Publish Profile Name>"
- Add the following lines to a project configuration
<DeployOnBuild>True</DeployOnBuild>
<PublishProfile>Deploy2</PublishProfile>
<PublishProfile>Deploy2</PublishProfile>
Using option 2 works better with multiple websites in the same
solution
Also for File System Publish update publish profile like this, because of a bug in the build:
<publishUrl>$(MSBuildThisFileDirectory)..\Deployment\</publishUrl>
$(MSBuildThisFileDirectory) - the location of the pubxml in the project properties
Friday, March 22, 2013
Private accessors and TFS2012 Builds
sometimes old test containing privert accessors will fail the build with Error:
C:\Program Files
(x86)\MSBuild\Microsoft\VisualStudio\v10.0\TeamTest\Microsoft.TeamTest.targets
(14): Object reference not set to an instance of an object.
first try to remove the private accessors and use a mocking framework (pex/moles or VS2012 Fakes)
But if due to any reason, you cannot remove the usage
of private accessors immediately from your tests, please try changing
the TeamTest targets file ("C:\Program Files
(x86)\MSBuild\Microsoft\VisualStudio\v10.0\TeamTest\Microsoft.TeamTest.targets")
and see whether running the shadow task in a separate process works or not.
Here are
the steps you should do for this: -
- Edit the targets file ‘C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\TeamTest\Microsoft.TeamTest.targets’.
- Change ExecuteAsTool property (highlighted) from default false to true.
<Target
Name="ResolveTestReferences"
Condition="'@(Shadow)'!=''">
<BuildShadowTask
ExecuteAsTool="True" <!—Default value is false, change it to
true –>
CurrentResolvedReferences="@(ReferencePath)"
CurrentCopyLocalFiles="@(ReferenceCopyLocalPaths)"
Shadows="@(Shadow)"
ProjectPath="$(ProjectDir)"
IntermediatePath="$(IntermediateOutputPath)"
SignAssembly="$(SignAssembly)"
KeyFile="$(AssemblyOriginatorKeyFile)"
DelaySign="$(DelaySign)">
<Output
TaskParameter="FixedUpReferences"
ItemName="ReferencePath"/>
<Output
TaskParameter="NewCopyLocalAssemblies"
ItemName="ReferenceCopyLocalPaths"/>
</BuildShadowTask>
</Target>
- Save the file. (and probably restart the machine as well so that the background msbuild processes definitely picks up the change)
RoboCopy Exit Codes
During my work at Capito ,i came to a client were wanted a Build-Deploy-Test using Lab build.
the build part worked well but we had a small problem with the deployment scripts.
we were using RoboCopy in the deployment scripts. apparently the return code are very different:
i found this at http://ss64.com/nt/robocopy-exit.html
the build part worked well but we had a small problem with the deployment scripts.
we were using RoboCopy in the deployment scripts. apparently the return code are very different:
The return code from Robocopy is a bit map, defined as follows:
Hex
|
Decimal
|
Meaning if set
|
0×10
|
16
|
Serious error. Robocopy did not copy any files.
Either a usage error or an error due to insufficient access privileges on the source or destination directories. |
0×08
|
8
|
Some files or directories could not be copied
(copy errors occurred and the retry limit was exceeded). Check these errors further. |
0×04
|
4
|
Some Mismatched files or directories were detected.
Examine the output log. Some housekeeping may be needed. |
0×02
|
2
|
Some Extra files or directories were detected.
Examine the output log for details. |
0×01
|
1
|
One or more files were copied successfully (that is, new files
have arrived).
|
0×00
|
0
|
No errors occurred, and no copying was done.
The source and destination directory trees are completely synchronized. |
You can use this in a batch file to report anomalies, as follows:
if errorlevel 16 echo ***FATAL ERROR*** & goto end
if errorlevel 15 echo OKCOPY + FAIL + MISMATCHES + XTRA & goto end
if errorlevel 14 echo FAIL + MISMATCHES + XTRA & goto end
if errorlevel 13 echo OKCOPY + FAIL + MISMATCHES & goto end
if errorlevel 12 echo FAIL + MISMATCHES& goto end
if errorlevel 11 echo OKCOPY + FAIL + XTRA & goto end
if errorlevel 10 echo FAIL + XTRA & goto end
if errorlevel 9 echo OKCOPY + FAIL & goto end
if errorlevel 8 echo FAIL & goto end
if errorlevel 7 echo OKCOPY + MISMATCHES + XTRA & goto end
if errorlevel 6 echo MISMATCHES + XTRA & goto end
if errorlevel 5 echo OKCOPY + MISMATCHES & goto end
if errorlevel 4 echo MISMATCHES & goto end
if errorlevel 3 echo OKCOPY + XTRA & goto end
if errorlevel 2 echo XTRA & goto end
if errorlevel 1 echo OKCOPY & goto end
if errorlevel 0 echo No Change & goto end
if errorlevel 15 echo OKCOPY + FAIL + MISMATCHES + XTRA & goto end
if errorlevel 14 echo FAIL + MISMATCHES + XTRA & goto end
if errorlevel 13 echo OKCOPY + FAIL + MISMATCHES & goto end
if errorlevel 12 echo FAIL + MISMATCHES& goto end
if errorlevel 11 echo OKCOPY + FAIL + XTRA & goto end
if errorlevel 10 echo FAIL + XTRA & goto end
if errorlevel 9 echo OKCOPY + FAIL & goto end
if errorlevel 8 echo FAIL & goto end
if errorlevel 7 echo OKCOPY + MISMATCHES + XTRA & goto end
if errorlevel 6 echo MISMATCHES + XTRA & goto end
if errorlevel 5 echo OKCOPY + MISMATCHES & goto end
if errorlevel 4 echo MISMATCHES & goto end
if errorlevel 3 echo OKCOPY + XTRA & goto end
if errorlevel 2 echo XTRA & goto end
if errorlevel 1 echo OKCOPY & goto end
if errorlevel 0 echo No Change & goto end
i found this at http://ss64.com/nt/robocopy-exit.html
Subscribe to:
Posts (Atom)
