Does TFS download all working folders in build definition? - tfs

In my build definition under "Working folders", I have $/MyProject/Main/Source mapped to $(SourceDir).
Does that make it download all files in $/MyProject/Main/Source to $(SourceDir)? Or does it only download what is included within the solution that I'm building if it exists within $/MyProject/Main/Source?

It will download all files under that folder.
If you want to limit what it downloads you can add other paths to the workspace mapping and mark them as "cloak" which will indicate to TFS not to download the cloaked folders.

Related

TFS 2018 MSBUILD Download files task equivalent?

We are moving to TFS 2018 from 2012 and I'm working on migrating the builds. One of the builds has a few mtbwa:DownloadFiles activities in it but I don't see an equivalent way to do this in the new build system. We have a few utilities in a different branch that are used to build installers. So I need to download those utils before completing the build. How would I do this in the new build system?
If the files are in source control, then you can map the source directly in Get source step.
Then the files will be automatically downloaded to the $(build.sourcesDirectory) by deafult on the agent machine.
After that you can also add a Copy Files task to copy the files to any location as needed.
If the files are not in source control, you can also use the Copy Files task to copy them, but you need to make sure that the service account has the proper permission to access the source folder.
UPDATE:
If the team projects are in same collection, map sources in Get Sources step is also available. You need to manually specify the Server path (Click ... can only navigate to the root path of current team project).
e.g.:
In below screenshot I entered the server path $/2017ScrumProjectFromVS/WpfTest
This also works with the Copy Task, that means you can copy the files directly from another team project which in the same collection.

TFS add folder and files to checking automatically

I've have a Solution with Projects I can add to TFS and everything works fine. But I have a background task which generates some yml files outside of my project
Structure:
sln
project1
project1.csproj
serialization
Folder1
*.yml files
Folder2
*.yml files
FolderX
*.yml Files ...
and so on. The structructure under the serialization Folder is "dynamic" and files and folders getting added automatically.
At the moment I need to add the new files and folders directly in the source control explorer by adding new items to the TFS and selecting the serialization folder and the next time when new files and folders are added I need to do this again, ....
Is it possible to say the TFs that i should include all Files and Folders in directory "serialization"?
Use local workspaces; any files added to the mapped workspace will appear a special "Detected: added files" heading under the Pending Changes pane of the Team Explorer, which can then be promoted to include in your pending changes.

Can we create TFS build definition of website without .proj file

I am using TFS 2015 for creating builds of application. I am able to create build template for web application as web application have both .sln and .proj.
But for Websites, I only have .sln file and no .proj.
How can I create Build definition in TFS 2015 for website having only .sln file?
As #Cece said, the answer is yes, you can run the MSBuild on the server without a .csproj.
I am assuming that your project is not running on the final version of the .Net Framework. In your case I suggest you to make this change
https://stackoverflow.com/a/42493822/819153
Then you should copy all the files from the PrecompiledWeb folder, and there you should find your .sln
Sometimes there are vb/cs projects that I have seen that they do not come with a project file, csproj or vbproject. They run with the .NET Framework 2.0. For those, you can create a build definition just to compile the .sln, but when you deploy the application, you need to copy the entire PrecompiledWeb folder to the IIS folder on your server. Try to add the task that has the option copy and publish and put all the changes to your server.
Check the privilege of the folder where you want to put the files, and be sure that the agent that is running the builds on the TFS has access READ/WRITE access to the server folder.
In your case, please check the .sln file, inside of it you should have a TargetPath, by default is PrecompiledWeb, but sometimes when you run the msbuild on the tfs you end with an error saying that the PrecompiledWeb can't be on the same tree of your solution, what you need to do then is putting a level up of your solution folder
Debug.AspNetCompiler.TargetPath = "..\..\PrecompiledWeb\YourProject"
Then on your CopyTask you need to change the CopyRoot directory, if you made any transformation before your build step to the webconfig, those transformations will be reflected on the PrecomiledWeb\YourProject. All the files in that folder should be deployed to the server folder path.
Lets say that you have this structure in your Branch
Branch/MyProject, then after you compile the source code on the TFS, your precompiled folder will be stored at the same level of your project on the agents folder. Please see the picture below to get the idea how to copy the files from the PrecompiledWeb.
The answer is Yes. You can create a build definition for a WebSite project by specifying the .sln file.

TFS Build Definition: prevent copy DLL to drop folder

We use TFS 2012 Build server for our Web Project
Build result is copied into folder _PublishedWebsites of Build drop folder
_PublishedWebsites contains all we need to deploy site later
But all DLL existing in _PublishedWebsites are repeated in the drop folder as well.
So we have in drop folder:
_PublishedWebsites
Bin
WebSiteLibrary1.Dll
WebSiteLibrary2.Dll
WebSiteLibrary3.Dll
logs
WebSiteLibrary1.Dll
WebSiteLibrary2.Dll
WebSiteLibrary3.Dll
How to configure Build Definition dll be copied only to _PublishedWebsites ?
You must customize the Build Template: or you tweak the final Copy to Drop Destination, but it could be easier to add a Delete files after that Activity, even if it is slower.
Please, check the names.

Preventing Checkin to trigger multiple Build with TFS 2010

I have some Libraries added in my TFS 2010 project in a Lib folder.
Each time I check In a dll in the Lib folder, all the build that reference that Lib folder trig automatically (more than 20 Build).
I can use the ***NO_CI*** to prevent that. But I prefer to have something automatic.
Is it possible to have an event handler on TFS to prevent that.
Ex. If the check in is on that folder, do not scan all the CI Build Workspaces to trig the build.
The workspace mapping in the build definitions defines which files/folders are part of that build. You can use cloaked folders to explicitly exclude folders from the workspace.
However, the workspace mapping is used for 2 purposes: to determine which files get downloaded to the build server as part of the build, and to determine which files trigger CI/Rolling/Gated builds.
If you exclude folders from the workspace (e.g. using cloaked folders) it will stop the builds from being triggered but it will also stop those files from being downloaded as part of the build.
If you want to have a build download a certain folder as part of the build but not have builds triggered by check-ins to that folder I don't believe it is possible without customizing the build workflow.
When you include a folder in a workspace, you're saying that changes to that folder affect your project. This is the same for changes to shared source code as for shared binary. If it changes, then the affected applications should be built (and their automated tests should be run) so taht it can be determined whether the changed files have broken anything.
Make sure each library in the lib folder has it's own folder + version folders beneath
lib
EntityFramework
4.1
EntityFramework.dll
4.2
EntityFramework.dll
Then modify your builds to only reference specific folders for the library a project references.
It takes a lot of work to setup builds, but will ensure the build only triggers when a file needed for the build is changed.
Alternatively a copy of each library in the projects directory, which you could manage with a package manager like NuGet or OpenWrap

Resources