File/Folder Structure in Team Foundation Service - version-control

When adding projects to TFS, I'll add a project for a specific website. This works fine, and all the folders and files within the root of the website are available in TFS. However, there are also shared files that are above the root of the website, and are not included in the specific website project/solution, since they reside outside the root of the website. For example, when I add existing files to a project, that are outside the root, it creates duplicates within the project. Or, when adding existing file to the project, it creates the wrong folder hierarchy in the project (appears as though the folder above the root is inside the website), which will result in problems with publishing and sharing source in TFS.
What is the appropriate way to include these files in the project, so that the files can remain outside the root, but be included in the project in TFS.

One way you might achieve this is by simply having one Team Project for all your websites, and logically break it up into different sites for backlogs/iterations/work items etc by using teams/areas. All your source code will be within the correct hierarchical structure within your one Team Project, and can then be shared between the subprojects within the Team Project.
See the following posts for a discussion of this approach:
Project of Projects with team Foundation Server 2010
When should I use Areas in TFS instead of Team Projects in Team Foundation Server 2010
One Team Project

Related

Getting started with Azure Repos: How do I upload files?

I am developing a game, and am looking for a way to manage version control between two computers. I was directed to use Repos.
I'm new to using version control at all, and when I try to follow tutorials for DevOps it talks about team coordination stuff that is NOT what I'm looking for. Honestly I'm not sure if this is the right solution for me.
I'm really trying to share files between two computers. Not just code, but also textures, meshes, level data, sounds, and ultimately the entire project. (And have a system to push/pull this data between computers, of course.)
I made a project within DevOps, but when I go to "Files" in Repos, I only have options to connect to a Git. How can I select files I need to share? Not just Visual Studio files, but my game's assets and other files?
Or is this even an option? Am I looking at the wrong service here?
You can clone the repository which contain the files you want to share in one project and import this repository in another project.
The document about cloning repo:
https://learn.microsoft.com/en-us/azure/devops/repos/git/clone?view=azure-devops&tabs=visual-studio
The document about importing repo:
https://learn.microsoft.com/en-us/azure/devops/repos/git/import-git-repository?view=azure-devops

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.

Share secure file(s) across team projects in VSTS

The company I work for currently has several projects in TFS 2015, each with their own build definitions.
We are in the process of transitioning from TFS to VSTS.
One of the features of VSTS that we were trying to utilize in the builds is the Secure Files in the projects' Library, to store the certificate issued by our company used for digitally signing assets in different installers.
It is currently duplicated in each project.
We were planning on uploading the certificate to one project and then use the 'Download Secure File' task in all of the projects' builds (that need it), to eliminate the maintenance of having the same certificate in multiple projects.
Not surprisingly, after uploading to one project, the file is not listed in any other project's Library or available for download as part of the build, even if I try to assign the project(s)/team(s) as a security role to the secure file (even giving it Administrator role).
Is there a way to have a secure file in one project's Library be shared across other projects, so that it can be downloaded as part of a build task?
It's not a big secret that the VSTS team has been working towards making individual projects portable. To allow you to take a project, with all that belongs to it, and then move it to another account. No clue when or even if this will ever be released, but it serves as a basis behind some of the separation between separate team projects.
In order to make this seamless, direct links and dependencies between projects are actively being discouraged and old features that are cross-project are slowly disappearing from the UI (even if the API supports it in many cases).
I suspect that if you configure the builds scope to be "Collection" that the REST API will be able to access the secret file from the other project, but it would require a custom task.
The guidance would be to replicate the secret file to each team project that needs access to it.

How to allow a user to access only specific projects in my solution

I'm using VSTS on Visualstudio.com to host our Solution. I have one solution with multiple Visual Studio projects, all hosted in a Team Project inside TFS. Now I'll have some one to help me with development, but I don't want him to have access to all the Visual Studio projects, only some of them. How can I give him access to some of the Visual Studio projects while denying access to the other ones?
If you are using TFVC as source control, you can refer to these steps below:
Add the user to your VSTS
Go to the admin page of that team project
Select Security tab
Click Create group to create a new group (e.g. CodeGroup)
Set View project-level information to Allow in Permissions tab
Add the corresponding user to that group in Members tab
Click Version Control tab
Select the folder of the project (one of the project in your solution folder)
Click Add to add CodeGroup (step4)
Set Read and Check in permissions to Allow
If you are using Git as source control, you can’t set the security for an item (project in a solution) in the repository.
On the other hand, If there are some project references that the user can’t access, I recommend that you can package and push the assembly to the feed of your VSTS: Package Management in Team Services and TFS