How to use a recurring Integration Endpoint for importing data
You are here
Using Git in PackagesLocalDirectory
How to use Git with PackagesLocalDirectory
Git is a more modern source control system that has a lot of interest from Finance and Operations technical resources. There are a lot of potential benefits to use Git rather than TFVC. However, one of the hurdles to larger adoption of Git from X++ Devs is how Git really likes you to make new repos from an empty folder. If i want to sync to a new repo, Git would like that new repo to be a new folder on my local file system. F&O VMs are created with the PackagesLocalDirectory already there and full of code. So what can we do? Bodge something together. We can use Powershell to move the repo into a directory once we've synced to an alternative location first. Updated based on a question from Ian Jansen.
First, Open Visual Studio. From the Team Explorer tab, click "manage connections" then click "Connect to a Project".
Find the project, then clone it. This must be a Git Repo. Note the path for use later.
Next, close Visual Studio and install Git from https://git-scm.com/download/win accepting the defaults if you're uncertain what the installer is asking you.
Next, Open PowerShell as an admin to run the following commands. Update the paths to what is appropriate for your scenario first.
Copy-Item "C:\Users\Admin3147856e63\source\repos\ABC Business Company Incorporated\.git" "K:\AosService\PackagesLocalDirectory\" -Recurse
cd k:\AOSService\PackagesLocalDirectory\
git reset --hard
Get-Acl -Path k:\AOSService\PackagesLocalDirectory | Set-Acl -Path k:\AOSService\PackagesLocalDirectory\.git
Remove-Item "C:\Users\Admin3147856e63\source\repos\ABC Business Company Incorporated" -Recurse -Force -Confirm:$false
Next, update the .gitignore file is K:\AosService\PackagesLocalDirectory\ to exclude everything that isn't an extension. This may be optional depending on the state of your repo and .gitignore file. Update the paths for your specific scenario first and add at the end of the file
# F&O specific
# Ignore everything
/*# But keep custom package and models for Package "ABC Business Company Incorporated"
# This will capture all models the descriptors for the package
# ABC Business Company Incorporated
!/ABC Business Company Incorporated
# bin isn't required in source control, it'll be created/updated during build if needed
ABC Business Company Incorporated/bin/
# resources isn't required in source control, it'll be created/updated during build if needed
ABC Business Company Incorporated/resources/
# XppMetadata isn't required in source control, it'll be created/updated during build if needed
ABC Business Company Incorporated/XppMetadata/
# All other logs or build outputs are not needed in source control
ABC Business Company Incorporated/*.xml
ABC Business Company Incorporated/*.log
ABC Business Company Incorporated/*.txt
ABC Business Company Incorporated/*.xref
ABC Business Company Incorporated/*.$usr# Also keep any binary package that may be in source control for binary package "Binary Company"
# this will keep all files and folders with files in folder "Binary Company"
!/Binary Company# keep VS Projects in PackagesLocalDirectory\Projects
!/Projects# Also include the following files in root of PackagesLocalDirectory
!.gitignore
# YAML Pipeline for DevOps
!azure-pipelines.yml
# settings for NuGet for Pipeline
!nuget.config
# packages references for NuGet for use in Pipeline
!packages.config
Next, open VS again. From the Team Explorer tab, add a new local Git repo.
Double Click on it.
Go to Changes.
Next, we should see the changes to our .gitignore file.
If we see the changes, that means everything worked as expected. From here, we'll need to refresh models, then build the ABC Business Company model in this example. We can now develop as normal as if we were using TFVC and we shouldn't notice any major differences with the development experience.