I inadvertently added my new console application to TFS (I didn't even check it in) and now it tries to connect to TFS when I open the solution.
What do I need to remove TFS references from my console application?
Open up your solution (.sln) file in notepad. Remove the section that has references to Scc like below
GlobalSection(TeamFoundationVersionControl) = preSolution
SccNumberOfProjects = 2
SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
SccTeamFoundationServer = http://mytfs:8080/tfs/ieb
SccLocalPath0 = .
SccProjectUniqueName1 = ConsoleApp3\\ConsoleApp3.csproj
SccProjectName1 = ConsoleApp3
SccLocalPath1 = ConsoleApp3
EndGlobalSection
Also, remove the .vssscc file from the directory where your Solution (.sln) file directory.
Related
How to make Flume Spooling Directory Source work with the Sub Directories of a folder too.
My source folder have several other folders too, I want my flume agent to look into these sub directories too for a file to dump it into sink.
Is there any way to do it?
The Spooling Directory won't check any of subdirectories, unless you explicitly configure it to check those subdirectories, eg:
a1.channels = ch-1
a1.sources = src-1 src-sub-1 src-sub-2
a1.sources.src-1.type = spooldir
a1.sources.src-sub-1.type = spooldir
a1.sources.src-sub-2.type = spooldir
a1.sources.src-1.channels = ch-1
a1.sources.src-sub-2.channels = ch-1
a1.sources.src-sub-1.channels = ch-1
a1.sources.src-1.spoolDir = /var/log/apache/flumeSpool
a1.sources.src-sub-1.spoolDir = /var/log/apache/flumeSpool/subdir
a1.sources.src-sub-2.spoolDir = /var/log/apache/flumeSpool/secondSubdir
In the currently release version of Flume (1.6.0) there isn't a way to do so however there is an issue being worked on to do this:
https://issues.apache.org/jira/browse/FLUME-1899
There is a patch available in the issue - this may/may not help you depending on whether you're able to build a custom Flume deployable.
a1.sources.src-1.recursiveDirectorySearch=true
It will check all sub-directories present in directory.
I want to customize the creation of a TFS project using TFS 2010 SDK.
I have already create a process template and use this sample, but I want to create a specific directory tree for the new team project base on a XML file which describe the tree. My problem is this message; The array must contain at least one element.
Parameter name: checkinParameters.PendingChanges
I initialize the TFS, map the server folder with a local folder and create directories in both.
fooString = Array.Find<WorkingFolder>(workspace.Folders, m => m.ServerItem.Contains("$/FR_DEV"));
Directory.CreateDirectory(ElementPath);
Directory.CreateDirectory(fooString.ServerItem + ElementTfsPath);
After that:
PendingChange[] PendingChanges = workspace.GetPendingChanges();
// Checkin the items we added
int changesetForAdd = workspace.CheckIn(PendingChanges, "Project creation.");
However, I get an error for the pending change! How can I fix this?
my problem was that i need to add the directory in the workspace not with a simple path
workspace.PendAdd(currentSubDirectory, true);
I have some TFS 2010 build definitions that were created under ProjectX. Now the source code has moved to a folder subordinate to ProjectY. How can I move the build definitions to ProjectY so they display under the Builds node of the Team Explorer for ProjectY?
I don't think there is something out of the box to copy the build definitions from one project to another. However you should be able to do it using the TFS API. You will want to move the build process templates, which is what Pete is referring to, into the Build Process Template folder for the new project. After that you would do something like:
var server = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("<server uri>"));
IBuildServer buildServer = server.GetService<IBuildServer>();
var buildDetails = buildServer.QueryBuildDefinitions("Project X");
foreach(var build in buildDetails)
{
var buildDefinition = buildServer.CreateBuildDefinition("Project Y");
buildDefinition.Name = "Copy of " + build.Name;
buildDefinition.BuildController = build.BuildController;
// This finds the template to use
buildDefinition.Process = buildServer.QueryProcessTemplates("Project Y")[0];
buildDefinition.ProcessParameters = build.ProcessParameters;
buildDefinition.Save();
}
A couple of things to note. You will need deal with converting the workspace mappings from one project to the other. You will also need to change the buildDefinition.Process line to find the specific template.
A powershell version of Sean's answer above
# Copy some TFS build defintions from one project collection to another
[void][Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Client")
[void][Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.VersionControl.Client")
[void][Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Build.Client")
$tfsUrl = "http://lontfs_at:8080/tfs/XXX"
$tfs = [Microsoft.TeamFoundation.Client.TeamFoundationServerFactory]::GetServer($tfsUrl)
$vcs = $tfs.GetService([Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer])
$buildServer = $tfs.GetService([Microsoft.TeamFoundation.Build.Client.IBuildServer])
$buildDetails = $buildServer.QueryBuildDefinitions("Project X");
foreach( $build in $buildDetails)
{
$buildDefinition = $buildServer.CreateBuildDefinition("Project Y");
$buildDefinition.Name = "Copy of " + $build.Name;
$buildDefinition.BuildController = $build.BuildController;
# This finds the template to use
$buildDefinition.Process = $buildServer.QueryProcessTemplates("Project Y")[0];
$buildDefinition.ProcessParameters = $build.ProcessParameters;
$buildDefinition.Save();
}
In VS2010, the TFS Power Tools can move a build definition from one project to another as demonstrated in the 2nd answer in this link: Is it possible to Export TFS 2010 Build Definitions?, and as shown below.
c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>tfpt
builddefinition /collection:"http://ServerX:8080/tfs/Collection X" /clone "Project 1\Build
Definition X" "Project 2\Copy of Build Definition X"
The TFS Power Tools for VS2010 can be downloaded from: http://visualstudiogallery.msdn.microsoft.com/c255a1e4-04ba-4f68-8f4e-cd473d6b971f
Uggly but very efficient way to move (not to duplicate) only one or two Build Definitions:
Open SQL Server Management Studio,
Open your Collection DB
Edit the table tbl_BuildDefinition
Replace the current GroupId with the target Team Project's GroupId
That's it ;)
To determine the GroupId of the target Team Project, simply find any BuildDefinition of that Team Project in tbl_BuildDefinition and take its GroupId.
For sure, you have next to update the BuildDefinition's workspace, Items to build, ... to use the server path of the new Team Project !
If you get an error like "GroupItem cannot be move accross Team Project" when updating your BuildDefinition, it was most probably already open before updating the DB. Close and reopen it.
If you don't intend to repeat this operation too often, it's IMO the fastest solution.
V.
Build definitions are just another source controled file in TFS, you should be able to open the build definition in ProjectX and save it as a new file to projectY's build definitions folder.
Edit
In the above post I am assuming ProjectX and ProjectY are TFS projects, in which case their workflow build definition(s) are simply in the builddfinitions folder of their respective source control roots.
Sean's answer helped me out, but in my case, I have only one repository for my build templates and custom activities assemblies. So I don't need to edit settings, I just want to copy one build definition from TFS Project A to TFS Project B.
Here is my 'short' version of Sean's code:
var server = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("TFS URL"));
IBuildServer buildServer = server.GetService<IBuildServer>();
var buildDetails = buildServer.QueryBuildDefinitions("Proj_A");
foreach(var build in buildDetails)
{
var buildDefinition = buildServer.CreateBuildDefinition("Proj_B");
buildDefinition.CopyFrom(build);
buildDefinition.Save();
}
How can I programmatically add files to a TFS project that have code behind files. I can say the following to add files. That will only add single files to a project and not the file plus the code behind file. I'm trying to add a resource file and it's code behind that were dynamically generated to a TFS project.
workspace.PendAdd(filesWithPathToEdit, true);
I had to put it in a T4 template to get access to the current Visual Studio DTE otherwise it would randomly work if I tried it outside of a t4. You can use the DTE to get a list of projects from a solution then add a ProjectItem and it contains ProjectItems so you can add your code behind there. ResxContainer is a custom class to just contain all information about my resx file i needed.
EnvDTE.DTE dte = (EnvDTE.DTE)HostServiceProvider.GetService(typeof(EnvDTE.DTE));
//dte = (EnvDTE.DTE) hostServiceProvider.GetService(typeof(EnvDTE.DTE));
//dte = (EnvDTE80.DTE2)Marshal.GetActiveObject("VisualStudio.DTE");
Projects projects = dte.Solution.Projects;
if (projects.Count > 0)
{
IEnumerator enumer = ((IEnumerable)projects).GetEnumerator();
while (enumer.MoveNext())
{
Project proj = (Project)enumer.Current;
if (proj.Name == projectName)
{
foreach (ResxContainer res in items)
{
ProjectItem item = proj.ProjectItems.AddFromFile(res.ResxPath);
item.ProjectItems.AddFromFile(res.CodeBehindPath);
}
}
}
There's no way for it to automatically know if a file depends on another. However, you can decide on your own which files will typically have a code behind file associated with them and add them yourself.
For example:
If you begin to add a file with an .aspx extension, then those files, as we know, typically have a code behind file. That code behind file, we can assume, has the same file name, with .cs appended. So, if we have "Default.aspx", then we can safely assume that there will be a "Default.aspx.cs" and that they are dependent on each other, so we should add both.
The same thing goes with .xaml and .xaml.cs files.
I want to set the maximum work item attachment size. From old blogs I have found that it is possible by calling SetMaxAttachmentSize, but the blogs are for older versions of TFS. I have found the new webservice path for TFS 2010.
http://localhost:8080/tfs/_tfs_resources/WorkItemTracking/v1.0/ConfigurationSettingsService.asmx/SetMaxAttachmentSize
Unfortunately when I call it like that I receive this error: This request can only be made against a project collection. The (.asmx) file should be located in the project directory (usually _tfs_resources under the application root).
I don't know how to format the call via a browser to target a specific project collection. Any thoughts?
Apparently SetMaxAttachmentSize web service was not leveraged on TFS 2010 therefore you need to do this programmatically, try running the following code:
TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer(#"http://yourtfsserver:8080/tfs/DefaultCollection");
ITeamFoundationRegistry rw = tfs.GetService<ITeamFoundationRegistry>();
RegistryEntryCollection rc = rw.ReadEntries(#"/Service/WorkItemTracking/Settings/MaxAttachmentSize");
RegistryEntry re = new RegistryEntry(#"/Service/WorkItemTracking/Settings/MaxAttachmentSize", "20971520"); //20MB
if (rc.Count != 0)
{
re = rc.First();
re.Value = "20971520";
}
rw.WriteEntries(new List<RegistryEntry>() { re });
I hope it works for you
Regards,
Randall Rosales
I have found that this works. It is easier than writing code.
Go to this url replacing <Collection> with your project collection: http://localhost:8080/tfs/<Collection>/WorkItemTracking/v1.0/ConfigurationSettingsService.asmx
Choose SetMaxAttachmentSize
You can test to make sure you set it correctly by going to the same url above and then selecting GetMaxAttachmentSize.