Created
April 18, 2020 09:23
-
-
Save Roald87/c68ea920607ec8f32d977d32f3f82712 to your computer and use it in GitHub Desktop.
Batch script to make hardlinks from a TwinCAT plc project to a Unit test project.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
title Make hard links from project to test project | |
echo This script will make hard links of the project files in the POUs folder to the test project folder. | |
echo Before running this script make sure you already created the neccesarry folder structure in your Plc or TwinCAT project. | |
for %%i in (.\path\to\project\POUs\*.TcPOU) do ( | |
mklink /H .\path\to\testproject\POUs\%%~nxi %%i | |
) | |
pause |
Hello,
Thank you for this batch file.
Is this line needs correction?
Manually add the .TcPOU files to the _MyProject\_Tests_ project
Like this?
Manually add the .TcPOU files to the _MyProject_Tests\Plc\POUs
Thanks @kumaraswamygaviyappa! Nice catch.
If the batch file is executed for the second time, Error is generated: A file cannot be created if it already exists.
Yes that is correct. You only have to link a file once.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to
Say you have a TwinCAT project called MyProject which you want to test with the TcUnit library. You create another project MyProject_Tests. So you have the following folder structure:
You then:
hardlinkPousToTestProject.bat
such that they point to the correct folders. So for the current example:for %%i in (.\path\to\project\POUs\*.TcPOU) do (
becomesfor %%i in (.\MyProject\MyProject\Plc\POUs\*.TcPOU) do (
mklink /H .\path\to\testproject\POUs\%%~nxi %%i
becomesmklink /H .\MyProject_Tests\MyProject_Tests\Plc\POUs\%%~nxi %%i
.TcPOU
files to MyProject_Tests\MyProject_Tests\Plc\POUs.gitignore
since this file is already in MyProject.Your file structure should now look like this:
Now you can change
Function.TcPOU
from either MyProject or MyProject_Tests!