TFS 2012 GetBranch Name during build - branch

There is an environment variable in TFS 2013 for Branch name. However my company still uses TFS 2012.
Does anyone know how I can get the branch name during build with TFS 2012?
Is there a class with the branch name property in the TFS Build api?
I haven't found one yet.
Thank you in advance

You can access the paths that are configured for this build through the IBuildDetails.
Just use the VersionControlServer class to query the
BranchObjects, then check which one is the root for your working
folder.
Sample Code:
IBuildDetail buildDetail = context.GetExtension<IBuildDetail>();
var workspace = buildDetail.BuildDefinition.Workspace;
var versionControlServer = buildDetail.BuildServer.TeamProjectCollection.GetService<VersionControlServer>();
var branches = versionControlServer.QueryRootBranchObjects(RecursionType.Full);
var referencedBranches = listOfFilePaths.GroupBy(
file =>
branches.SingleOrDefault(
branch => file.ServerItem.StartsWith(branch.Properties.RootItem.Item)
)
).Where(group => group.Key != null);
More details please refer jessehouwing's reply in this question: Include branch name in post build event on Team Build

Related

Microsoft.Graph, c# sdk, trying to get list of driveitems from onedrive root folder: Error "DriveRequestBuilder does not contain a definition for Root

.NET MAUI App,
I am trying to get a list of Children from Root folder on Drive... I get this error in edition/compile time, when I use a snippet of code from MS Learn:
'DriveRequestBuilder' does not contain a definition for 'Root' and no accessible extension method 'Root' accepting a first argument of type 'DriveRequestBuilder' could be found (are you missing a using directive or an assembly reference?)
I just cloned a sample project developed by microsoft staff and inserted a snippet of code from MS Learn.
Pls, get the entire project with the error here:
https://github.com/leoderja/DriveRequestBuilder_RootNotDefined.git
The error is in:
MauiAppBasic.csproj project ->
MSALClient folder ->
MSGraphHelper.cs file ->
TestRootChildrenAsync method
Using Microsoft.Graph version 5.0.0-rc.1
EDITION: Here a minimal example:
using Microsoft.Graph;
GraphServiceClient graphClient = new GraphServiceClient(new HttpClient());
var children = await graphClient.Me.Drive.Root.Children.Request().GetAsync();
The problem was Microsoft.Graph v5.00 rc1. When I set v4.50 the errors disappeared. I hope that Microsoft staff update the documentation with the changes when final release of v5 is available.
Since version 5 the Root is accessible through Drives[userDriveId] but not through Me.Drive
var children = await client.Drives[userDriveId].Root.Children.GetAsync();
If you don't know the user's drive id you need to call Me.Drive.
var driveItem = await client.Me.Drive.GetAsync();
var children = await client.Drives[driveItem.Id].Root.Children.GetAsync();

Rally Web Services REST API - Ruby Toolkit

I'm trying to update the Project an artifact belongs to. I am not getting any errors but the artifact's Project does not change. I can successfully change the artifact's notes, name, and other attributes, but not Project. I'm not sure if I'm specifying the Project name correctly in the call:
updated_artifact = #rally.update(:hierarchical_requirement, "FormattedID|" + artifact.FormattedID, {"Project.Name" => "Project A"})
Got help from CA Support and resolved this. If you want to update an associated/referenced field, you'll need to send the URL reference to the Project and supply whatever the OID of the project is, like so:
updated_artifact = #rally.update(:hierarchical_requirement, "FormattedID|" + artifact.FormattedID, {"Project" => "/Project/OID"})

The name 'NodaTimeField' does not exist in the current context error during installation of index on RavenDB

I am using NodaTime's LocalDate in RavenDB index.
Here is an example of the index:
public class TaskIndex : AbstractIndexCreationTask<ScheduleTask>
{
public TaskIndex()
{
Map = tasks => from task in tasks
select new
{
task.Name,
PlannedStartDate = task.PlannedStartDate.AsLocalDate().Resolve(),
PlannedDueDate = task.PlannedDueDate.AsLocalDate().Resolve()
};
Index(x => x.Name, FieldIndexing.Analyzed);
Store(x => x.Name, FieldStorage.Yes);
TermVector(x => x.Name, FieldTermVector.WithPositionsAndOffsets);
}
}
I installed RavenDB-NodaTime bundle as described here.
Here is a piece of code I use to install index:
var assembly = AppDomain.CurrentDomain.Load(new AssemblyName
{
Name = "cs.Scheduling"
});
var catalog = new AssemblyCatalog(assembly);
var provider = new CompositionContainer(catalog);
var commands = documentStore.DatabaseCommands.ForDatabase(dbName);
IndexCreation.CreateIndexes(provider, commands, documentStore.Conventions);
documentStore is configured with default database, but then I use it to install index to different (tenant) database name of which comes in dbName.
During the installation of the index I got an exception: The name 'NodaTimeField' does not exist in the current context.
I have one default database which is completely different from database I try to install index for. So basically the case is similar to one described here but I am using standalone version of RavenDB server.
I tried to find out how I can do suggested there but was not able to do that:
embeddableDocumentStore.ServerIfEmbedded.Options.DatabaseLandlord.SetupTenantConfiguration += configuration =>
{
configuration.Catalog.Catalogs.Add(new TypeCatalog(typeof(DeleteOnConflict)));
configuration.Catalog.Catalogs.Add(new TypeCatalog(typeof(PutOnConflict)));
};
Version of RavenDB I am using is 2.5.2956.
RavenDB.Client.NodaTime - 2.5.10.
Hope for your help. Thanks.
In my case that was a very silly mistake. When I was installing RavenDB server some time ago I installed it into non-default destination. Later some RavenDB updates were installed into default destination (i.e. \Program Files (x86)\RavenDB). And when I was installing RavenDB-NodaTime bundle I put it into incorrect destination (\Program Files (x86)\RavenDB).
After detecting this issue and configuring RavenDB server in my correct destination properly an error described in the heading has gone away.
Hope this answer can help somebody else.
P.S. Later there was a deserialization error during reading data from db (RavenDB was not aware of how to deserialize date from string in "yyyy-MM-dd" format to LocalDate object) which I fixed by calling store.ConfigureForNodaTime(DateTimeZoneProviders.Tzdb); after store.Initialize(); call as Steven suggested in his answer.
I believe the answer is that your tenant database does not have the bundle "activated" Your database document (under settings in Raven 3) should have something like
"Raven/ActiveBundles": "Encryption;Compression;NodaTime"
Also you must call
store.ConfigureForNodaTime(DateTimeZoneProviders.Tzdb);
I call this after store.Initialize(). Once you do both of these things, you may have to fix existing data by re-saving your documents (not sure if there is another way). New data will be properly stored like '2016-2-3' format which should make your index return data.

CRM 2015 update - plugin error - 'Changing security attributes is not allowed in stage 20 plugins'

When i tried to create another type of an entity record in the post update plugin stage I have gotten "Changing security attributes is not allowed in stage 20 plugins" error.
Its working fine in Dynamics CRM 2013 SP1 CRM.
After update CRM 2013 to CRM 2015 i got this error
Remove logic from pre create and move it to post create of the other entity. then it will working fine
Remove unwanted attribute from plugin images.only select attribute that you need in the plugin.You can set it when you registering plugin(don't tick all attributes check box).remove security related attribute(owner, modified by, created on)
Some of you might get this error in the plugin steps when an organization is being migrated to CRM 2015.
Cause:
You change the ownership of the record in the record Pre-creation
Resolution:
Most solutions out there say about change the plugin to Post-operation stage, but this don't make sense for some of the actions/checks that your plugin could do.
So, what you could do is to check the pipeline stage before you run the assignment operation.
https://msdn.microsoft.com/en-us/library/gg327941.aspx#bkmk_PipelineStages
Sample code:
//Runs on the Pre-Validation step, when a Contact is created
if (context.Stage == 10)
{
if (!targetEntity.Attributes.Contains("parentcustomerid"))
{
throw new InvalidPluginExecutionException("Message to show....");
}
try
{
var accountOwner = (from a in orgServiceContext.AccountSet
where a.Id == targetContact.ParentCustomerId.Id
select a).Single();
targetEntity.Attributes["ownerid"] = new EntityReference("team", accountOwner.OwnerId.Id);
targetEntity.Attributes["owningbusinessunit"] = new EntityReference("businessunit", accountOwner.OwningBusinessUnit.Id);
}
catch
{
throw new InvalidPluginExecutionException("Message to show...");
}
}
Found another solution: Move your plugin step to Pre-Validation.

How to include custom web.config files as part of package?

I'm a newbie at SharePoint 2010. I right-click on the project, select Deploy if I want to deploy locally. The Site URL on the project is set to my local machine. If I want to deploy to the QA server, I select Deploy, navigate to the Debug/Release folder, grab the .wsp file, logon to the Central Administration on QA, retract the solution, then do Add-SPsolution <path to wsp file> through powershell, go back to Central Admin, the click on Deploy solution for that package. Works fine.
The web.config on my local machine has a custom connection string, and appsettings. When I deploy the package on the QA server, I'm manually changing the connection string and appsettings specific to QA. I want to automate this process. I want the web.config to be part of the package with it's own custom connecting string (one for local, one for QA, and for Production) and appsettings. How do I do it? The goal is on a new machine, I should be able to deploy the wsp and appsettings+web.config should all be correct without modifying anything manually. How do I accomplish this?
I am pretty sure web.config modifications can't be done with just package files / CAML.
However, what can be done is to deploy a WebApplication Feature Reciever which modifies the web.config through SPWebApplication.WebConfigModifications.
Here is a snippet of code from my project, see the the Code Project KB for more details: (This first bit is just a handy function with some notes.)
// For WebConfigModifications access,
// see http://www.codeproject.com/KB/sharepoint/SPWebConfigModTool.aspx
// Hints:
// app.WebConfigModifications.Add(new SPWebConfigModification
// {
// Type = [add/update child node?]
// Path = [XPath of parent node]
// Name = [XPath to identify child node UNIQUELY]
// Owner = [Use GUID to identify as ours]
// Sequence = [Sequence number, likely 0 for only one]
// Value = [XML node to add/update]
// });
void ModfiyWebConfig (SPWebApplication app, string path, string name, XElement node)
{
app.WebConfigModifications.Add(new SPWebConfigModification
{
Type = SPWebConfigModificationType.EnsureChildNode,
Path = path,
Name = name,
Owner = OwnerId,
Sequence = 0,
Value = node.ToString(),
});
}
Get/init SPWebApplication
var app = properties.Feature.Parent as SPWebApplication;
Queue/setup modifications
ModfiyWebConfig(app,
"configuration/system.webServer/modules",
"add[#name='ASPxHttpHandlerModule']",
new XElement("add",
new XAttribute("name", "ASPxHttpHandlerModule"),
new XAttribute("type", aspxHandlerModule)));
Apply modifications
app.WebService.ApplyWebConfigModifications();
app.Update();