TFS workspaces in AX2012

I originally wrote the previous article – Shared vs. isolated Dynamics AX environments – primarily as an introduction to this post and to be able to refer to it. It provoked unexpected amount of discussion – and that’s great. The comparison of both approaches should help you to choose the most suitable one and point out some problems that may need to be dealt with. This post describes how to solve one of these problems – namely how to use multiple Team Foundation Server workspaces in a shared environment of Dynamics AX 2012 (not supported by default). The previous article should have shown you that you may want to use entirely different approach.

AX2012 supports only a single TFS workspace and that is created as private, so version control in such environment can’t be used by anybody but the owner of the workspace. One solution is a public workspace – that works well as long as you are aware of its limitations. Strictly speaking, the public workspace is – from TFS perspective – still used by a single user – its owner. For example, if a file is checked out from version control, TFS knows in what workspace the file is used and knows what user owns the workspace. But it knows nothing about what user currently uses this public workspace.

If you want to use the environment for normal development, public workspace probably won’t suit you very well. So if you plan using shared AX2012 environment and TFS, you should think about how to solve this problem before starting the implementation.

You probably won’t do without multiple workspaces and as it was said, AX2012 doesn’t support them out of the box, therefore it requires a code change. Every user should have his own (private) workspace, but because common code is used in shared environments, workspaces need to use the same code as well (see also AX TFS FAQ). The solution is to create a separate folder (and workspace) for every user and redirect them to a single common folder. You can use junction points or symbolic links for this purpose.

That’s exactly what is provided by the extension described below. It allows defining workspaces for individual users and creating symblic links right from Dynamics AX. And of course, it changes application logic to use these new workspaces.

Addax

Before describing the extension itself, I must mention one more thing that the extension depends on and that is included in the .xpo. I developed a simple system for my own needs to manage various developer-oriented extensions and the modification for private workspaces is one of its plugins. Although I currently don’t plan to publish any other plugins and having a whole system for a single plugin is obvious overkill, I’ve decided that it may be useful for others, at least for inspiration.

I call it Addax, which is an abbreviation for Addons for AX and also an animal. 🙂

Installation

The zipped .xpo is downloadable from here. Import it to Dynamics AX 2012 (developed in RTM version).

The .xpo contains several standard objects – not many, but still you should ensure yourself that there is no conflict.

Version control setup

Version  control setup doesn’t contain any parameters for individual workspaces. The folder set as Repository folder is simply used as parent of all workspaces.

When you finish the configuration described below, come back to this dialog and enable version control.

Plugin activation

In the imported project (AddaxWorkspaces), find and run the AddaxPlugin menu item. The form doesn’t contain any plugin in this moment, so search for plugins by pressing Update plugins button. Activate User repository plugin and go to configuration by the Configure button.

Workspace configuration

Configuration is simple – just create a new record, choose a user ID and save. The path to the workspace is automatically assembled from the repository path (defined in version control setup) and user’s Alias.

The corresponding folder is created simultaneously with saving the record:

Here are symbolic links for users administrator and hal and a common folder Shared which all links point to (and which is also created automatically).

You can easily see the target object in link’s properties.

When deleting a record in the form, the corresponding link is removed too.

This solution has some theoretical limitations, for example it can’t be used for two users with the same alias (but different domains) but I don’t think it is a real problem.

Workspace is not everything

It’s great to have a separate workspace for every user, nevertheless AX 2012 expects that there is just one workspace. For example, if AX needs a list of checked-out objects, it asks TFS for objects in the given workspace. It obviously knows nothing about other workspaces.

Could it be changed? Sure, it could. I didn’t implement it simply because I haven’t needed it so far.

18 Comments

  1. Hi,

    In Ax 2012, we are trying to configure TFS as our Version Control System. So we created a temporary team project
    “TempAx2012” in our domain. Using this we were able to properly connect &
    configure the TFS on Ax 2012 client & performed the operations normally.

    Now we have TFS that is present on cloud https://app.tfspreview.com/defaultcollection which we would like to configure with Ax 2012 client. So the Ax TFS projects will be present on cloud.
    We are facing issue when configuring Ax 2012 client with the TFS present on this cloud. We are gettingthe following issue:

    Team Foundation services are not available from server https://xyz.tfspreview.com/defaultcollection. Technical information (for administrator): TF400813: Resource not available for anonymous access. Client authentication required.

    There was no popup for even entering the credentials.

    Please let me know if any body faced the same issue.
    Thanks,
    Sanjivkumar Kori.

    System Details –
    Server – Windows Server 2008 R2,
    Ax Version – Ax 2012 CU3.

  2. Hi. Thank you so much for this app. I’m trying to get it installed but when creating a new user i get the error “A required privilege is not held by the client. Traced back to Class: AddAXUserRepository.createFolder. Can you assist in any way.

    • This error is related to file system permissions. Check your permissions for the folder, run the process as administrator and disable UAC. Hopefully one of these things helps.
      I’ve never experienced any issues, on the other hand I’m always local administrator.

  3. Hi Martin, thanks for posting the plugin, it did the job for enforcing locking mechanism when using TFS and shared AOS topology. Just some points to mention: You cannot check-in labels because AX is throwing an error “Unable to check-in”, after some debugging I saw that the problem is in class SysLabelFile in methods allowLockDuringCheckIn and allowMultipleCheckout which always return true. This is probably defaulted to be like this for using it with private workspaces but we are using shared repository with private workspaces. If you set those two methods return values to false than you’ll be able to check-in the label file. Another thing is that nobody should use force sync from AX because everybody else will loose code all the time, so solution to this is just to hide the force checker from SysVersionControlSynchronization.

    • I don’t remember any problem that would really prevent us from checking labels in, we actually used that. I would say that the problem is not in the code itself but rather in your TFS configuration (so you try try to obtain a lock while the file already is already locked, for example). It would require to analyze the reason for “Unable to check-in”, but if you already use another solution, it makes no sense to bother with it.

      What we used when developing in a shared environment were disabled multiple checkouts and because developers had difficulties with using temporary label IDs correctly, I disabled them too (by a simple code change). Developers didn’t create labels when developing – only when they were done, they checked out the label file, replaced all texts by labels (by a custom tool) and checked the file in.

      The default TFS integration is not ready for shared environments, so you have to evaluate carefuly how you want to use it in your own way and do the necessary changes. I would recommend to rather invest that time to get familiar with the way how AX-TFS integration was designed.

      Personally, if I could really choose, I would never work in a shared environment again. But we’re not so lucky every time…

  4. Hi Martin.
    Tthanks for your explanation. Let me ask you something. This package will work for AX2009 or some objects are only found in AX2012?
    Thanks;.

    • The same approach will work in AX 2009, but it’s possible that you’ll have to modify the code to fit into AX 2009.

  5. Hi Martin

    I have implemented the Pluggin that you developed and everything has been perfect with 2 users, each one has its workspace and I can see the change control.
    Per I have a problem when I wanted to implement a third user showed me the error at the time of initializing the TFS more specifically in this class SysVersionControlFilebasedBackEndTfs and the error is in the method init tfsConnectionManagerProxy = new Microsoft.Dynamics.AX.Framework.TeamFoundationServerFacade.ConnectionManagerProxy (tfsServer, TfsProject);
            In that line.
    The error is as follows TF30063: You are not authorized to access https://pangeatfstrial.visualstudio.com/.

    But the permissions have the user belongs to the same domain and everything is the same, in fact that error was fixed spontaneously in this third user but when implementing the fourth returns, the connection of these users with TFS is correct in the project that is But I do not know why it does not solve that web service?
    thank you very much for your attention.

    • The plugin merely creates symbolic links and changes the path that AX uses for its repository folder. It changes neither the way how AX communicates with VSTS nor how VSTS authorize users. You’re looking at a wrong place.
      Make sure that users have the right permissions in VSTS. Did the user get the dialog for logging in into VSTS? Also, when user can’t be authorized through AX, what happens if you try to do through VS installed on the same machine?

  6. Hi Martin,
    On an AX2012 R3 environment , I imported the ADDAX xpo, followed the steps to activate it . The reporsitory path in the versuion control parameters is \\Server\Workspaces\Main\Repository

    When I try to add users then getting an error
    System.ArgumentException: The UNC path should be of the form \\server\share.
    at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
    at System.IO.Path.GetFullPathInternal(String path)
    at System.IO.Directory.InternalCreateDirectoryHelper(String path, Boolean checkHost)
    at System.IO.Directory.CreateDirectory(String path)

    If i am missing a step somewhere in the setup?

    • First of all, try it with a local path – I don’t think that remote links are enabled by default. I wonder why you want to use a network path at all; it’s sounds weird to me.

      • Hi Martin,
        Thanks for your response
        If I give the local path and run AX as admin and try to enable then it does work seamlessly.
        The scenario is to have the repository kept as a network path at AOS and a development RDP server will allow developers to connect to AX environment for development. There could be a cluster of the RDP servers also possible

        If I create the “shared” folder manually under the Repository then i am able to create the user folders but i hit the roadblock when enabling the the version control parameter . When we press “ok” at the version control parameter it does not do anything ( no error and no success . form stays as is)
        Any idea ?

        • I would like to discourage from using UNC path for TFS repositories and dealing with remote symblic links.
          If you insist, use the debugger to understand what’s going on. Note that Microsoft miss handling of CLR exceptions there, so you probably get a CLR exception but it’s not displayed to you.

Comments are closed.