TFS 2010 and creating a package - deployment

I am running the build with the flags /p:CreatePackageOnPublish=true /p:DeployOnBuild=True
The agent creates a the folder:
C:\Builds\99\MyWebProject\Sources\WebProj\Web\obj\Debug\Package\PackageTmp
that is used when the package is deployed. However, this folder does NOT have the files that are not in source control but are created during the post build event. I'd like these files to be included in the package as well (but can't add them to the source control as they are created later).
How do I take care of this issue?

The only way I could do this was to add files to source control.

Related

Azure Pipeline generate a .sln/.csproj as part of the pipeline process from a folder

Is there a way to generate a solution and project file out of a folder structure through a azure pipeline .ymal stage?
The way the project has been set up is that there are lots of other .git repos set up inside a master repo and inserted though subtrees. These repos don't have a .sln in themselves but instead when they are added into Unity they get added into the projects .sln and a .csproj is generated for each of the assemblies within the submodule (package)
What I'm looking to do is to have documentation generated for each of these submodules whenever an update is pushed to its master (not the projects it lives in master) as these tend to be more utilities and self contained systems. Problem I'm facing is that I can trigger all the documentation system with docFX but because this module does not contain a .csproj I'm unable to generate the documentation for it. so I'm wondering if its possible to have a step where I can create a project file for all scripts that are within a folder structure, and as such then have a project file for docFX to work of.
I know its not ideal in any sense, but wondering if its a possibility while I investigate further into other solutions.
Is there a way to generate a solution and project file out of a folder
structure through a azure pipeline .ymal stage?
For this issue, I am afraid that azure pipeline is impossible to achieve this.
".csproj" is a Visual Studio .NET C# Project file extension. This file
will have information about the files included in that project,
assemblies used in that project, project GUID and project version etc.
This file is related to your project. It will be automatically
generated when we create
".sln" is a structure for organizing projects in Visual Studio. It
contains the state information for projects in .sln (text-based,
shared) and .suo (binary, user-specific solution options) files. We
can add multiple projects inside one solution.
Azure pipeline cannot generate a solution and project file according to the folder structure.

How do I build a VSTS project with an absolute-path reference folder?

I have two projects in TFS, WebSite and Reference, and they follow the structure:
$\
WebSite: Main project to be built
Reference: Repository with many referenceable dlls.
Website.dll uses dlls existing at Reference but, for several reasons, they are not contained in the same solution, and may be mapped to different folders that do not follow the VSTS structure.
So, in order to have the Website project compiling locally, the Reference's.dlls Hintpath at Website.csproj have been manually changed to a specific, absolute path, common to all developers' machine.
Now, we're experiencing with CI/CD, and we're thrilled with the hypothesis of having VSTS doing the dirty, tedious work of building/deploying. Thing is, since Reference.dll is not in the same project as Website, building ends up lacking essential libraries (the aforementioned Reference folder) and fails.
Is there a way of telling VSTS to GET Reference's dlls (which are compiled at this point), copy them to the directory Website.csproj is being built at and let them be used to build the main project?
What I've tried:
First:
Map Website and Reference in the Get Sources step
Using a Copy Files task, set Source FOlder as $\References and Target Folder as $(Agent.BuildDirectory)
Build
Now:
Added all the references in the main project.
In both cases, none of the references are found, and the
The type or namespace name '(namespacehere)' could not be found (are you missing a using directive or an assembly reference?)
errors are thrown.
I've been searching through the vsts help section, but can't seem to find any obvious solutions.
Any help is greatly appreciated.
It’s mainly caused by the Reference's dlls are not added in source control (TFVC repo).
First, please make sure you add the Reference's dlls into the website project. So the project file will contain the reference as below (ClassLibrary1.dll as the reference in below example):
<Reference Include="ClassLibrary1">
<HintPath>..\..\ClassLibrary1\ClassLibrary1\bin\Debug\netstandard2.0\ClassLibrary1.dll</HintPath>
</Reference>
Then you can use any of below options to make the referenced dlls work.
Option 1: add the referenced dlls into source control
If you have added .tfignore file into your TFVC repo, it will ignore files and folders under **\bin, so the reference dlls not checkin to TFVC repo by default. You can follow below options to checkin the reference dlls into TFVC repo:
Exclude the reference dlls in .tfignore
Exclude the dlls you want to refer in .tfignore. The format is:
!**\referencename.dll
Such as !**\ClassLibrary1.dll.
Add the reference dlls into source control
In VS -> Source Control Explorer -> Add items to folder -> selected the dlls.
Checkin and double check the dlls are added into TFVC repo
In VS pending changes window, there will show the dlls and the .tfignore file as Inculded changes, checkin the changes.
And double check the dlls are added into TFVC repo in VSTS web page.
Option 2: build the reference project before building website project
If you do not want to add the dlls into source control, you can also build the reference solution firstly so that the reference dlls will generate before build the website project. Details as below:
Edit build definition -> add VS Build task (specify reference solution) before building website project -> Save and queue the build.
Note: for option 2, the build configuration you specified in the relative path should be consistent with the build configuration in VSTS build definition.
Such as I specified Debug in the relative path ..\..\ClassLibrary1\ClassLibrary1\bin\Debug\netstandard2.0\ClassLibrary1.dll. So in my VSTS build definition, VS build task to build the reference project, the build configuration must be Debug.
Now, no matter which option you are using, VSTS build will not show the error message The type or namespace name '(namespacehere)' could not be found.
The correct way to approach this is to not store references in source control. Turn them into packages, store them in a package management feed, and restore them during build. Developers will automatically restore them on build.

TFS Builds - Put several files from other folders to one folder after building

In TFS Builds component I try to do this for instance, to put these files:
Main\Folder1...\bin\file1.dll
Main\Folder2...\bin\file2.dll
In one file such as: \Main\dll
I can do manually, for each folder, but if I have so much files I don't want to do that manually.
What I'd like
Thank you for helping me!
Add a Copy File step after the VS Build step. And in the Copy File step, set like the picture below: the Contents could be **\bin\$(BuildConfiguration)\*.dll and make sure that the Flatten Folders is checked.
Note:
The Flatten Folders only exists in TFS 2017 Update1 and upper version for on-premises. VSTS also has it. But in TFS 2017 and TFS 2015, it doesn't have.
So, if you are using lower version of TFS, you need to use 2 Copy File steps and copy the 2 dlls to the Main Folder separately. Or you could download the latest source code(it has the FlattenFolder option) of that step from here. Then package it and upload to your TFS as a custom build step.
You can use the MSBuild Arguments to achieve this. Just add the OutDir argument to the Build Solution Step like this:
/p:OutDir=$(Build.BinariesDirectory)
In this case, all of your files will end up in the Binaries Directory of your Build Agent. e.g. "C:\Agent1_work\1\b"
Of course you could also use a different target folder than whats inside the variable $(Build.BinariesDirectory).

How to create custom folder from the release folder of Windows Work flow for TFS Build process?

I have used the
/p:GenerateProjectSpecificOutputFolder=True for creating build for each and every project in my solution and now i wanted to customerize the folder structure on my needs. How can we achieve this?
enter image description here
If you are using XAML build, you can customize Binaries folder in TFS Team Build by modifying the build process template. Adding CreateDirectory Activity and FindMatchingFiles activity are necessary, following this blog for more details.
If you use the new build system, that will be much easier to manage artifacts. With task Publish Build Artifacts, you can specify contents in the task, also you can add as many Publish Build Artifacts task as you want to manage artifacts. More details, check http://www.codewrecks.com/blog/index.php/2015/06/30/manage-artifacts-with-tfs-build-vnext/
Alternatively you can extend your build definition with a PowerShell script at different points within the build:
Pre-build
Post-build
Pre-test
Post-test
Note I am using the TfvcTemplate.12.xaml template. This is the build template that comes with TFS 2013.

can you deploy data and no assemblies via a nuget package?

is it possible to use nuget to deploy test data instead of dlls?
we have some largish test data files which I don't want to keep in our git repository and I am wondering if we could deploy these to the test projects during the build by including them in a nuget package which gets installed during the build.
Is this possible?
Yes, but, without knowing a few more details about how your project is structured, it's difficult to tell you exactly how you would do this.
If you just want to copy your data files into a directory in your test project, you can just put the files in a content folder in a NuGet package, and it will copy them to your project automatically, much in the same way that it would copy DLLs. If this is all you need, you can create a package like this in a few minutes.
If you need to deploy the test data files to a directory outside of your project directory, or manipulate the file names or contents, you can do this as well. I usually create a tools package to do this.
I put the files I want to copy into a tools directory in my package, and then create a simple init.ps1 or install.ps1 script to do whatever copying and file manipulation tasks are required.
If you are intimidated by the prospect of creating packages from scratch, you may find NuGet Package Explorer helpful. You can create a content folder and drag the content you want to deploy into it:
http://npe.codeplex.com/