I have a TFS build in a Git team project that uses the default template. It builds a .proj file containing a single target that executes a .PS1 file in Powershell.exe.
The .PS1 generates its own log file. I have been trying to figure out how to get this file to copy to the drop directory \logs folder. From what I can tell, TFS only copies specific files to this output directory:
ActivityLog.AgentScope.[id].xml
ActivityLog.xml
build.log
Anyone tried getting custom logging info to this directory? I tried writing to build.log but that failed with errors.
I like #MrHinsh's answer better than mine, but I found that you can write to a file at this location: $(TF_BUILD_DROPLOCATION)\logs during build.
I assumed that since the path doesn't exist until the log files are copied it would not work. But it does... the TFS/MSBuild log files are simply merged in. And it even seemed to work with a name conflict. For example, if your file is named build.log, MSBuild's will be renamed to build.01.log.
In your PowerShell you can easily execute Host-Write to write to the Build log. All of the standers output methods are captured, although you need to use the "-verbose" tag to get the text to always write.
Related
My build fails with
Could not find a part of the path 'App_Data\aspnet-Definiti.Licencing.TestWebProduct-20171016042403.mdf'.
The file exists in in the file system
The file exists in Source Control
The get sources phase seems to find the file fine
2017-11-28T10:49:32.5448880Z Getting aspnet-Definiti.Licencing.TestWebProduct-20171016042403.mdf (no errors here)
Things I've tried:
Excluding the file from the project
Deleting the file in visual studio and checking in
Deleting the file in Source Control Explorer and Checking in
Setting the file to copy if newer
Setting the file to copy always
Unticking build in configuration manager for the offending project
The error always comes back.
Copying App_Data\aspnet-Definiti.Licencing.TestWebProduct-20171016042403.mdf to obj\Release\Package\PackageTmp\App_Data\aspnet-Definiti.Licencing.TestWebProduct-20171016042403.mdf.
2017-11-28T10:50:48.4423213Z ##[error]C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\VisualStudio\v15.0\Web\Microsoft.Web.Publishing.targets(2603,5): Error : Copying file App_Data\aspnet-Definiti.Licencing.TestWebProduct-20171016042403.mdf to obj\Release\Package\PackageTmp\App_Data\aspnet-Definiti.Licencing.TestWebProduct-20171016042403.mdf failed. Could not find a part of the path 'App_Data\aspnet-Definiti.Licencing.TestWebProduct-20171016042403.mdf'.
My final act of sheer desperation was to remove the entire project so at least the rest of the solution would build, but to my utter surprise the error still remains.
The solution was to set the file to do not copy and clear the MSBuild Arguments in the build definition.
I am actually trying to ignore a particular file to be included in the build. Actually it is a thumb.db file which is automatically created whenever images are encountered in a folder. My solution contains the image folder. So basically, whenever the build is triggered from JENKINS, it will create the thumb.db file.
Is there any way, I can ignore the Thumb.db file from getting created via JENKINS?
I can switch off the thumb.db file from creation by switching it off from my windows, but I have to do it every time a build is created from JENKINS. So I want to ignore the thumb.db file from creation.
Below is the Job creation flow in my JENKINS from my current project:
SCM
I have used the Team Foundation Server Plugin and have mentioned my SERVER URL and PROJECT PATH
POST BUILD steps simply create the build to the staging location(folder Location)
Any help is appreciated.
Thanks,
AFAIK, on windows you can turn it off or on for the whole system and not for particular folders.
So you have to choose. On or off.
If you still want to keep it on, you'l have to handle this in your Jenkins build scripts. Remove any thumbs.db files after build is done.
If your output is an archive, make sure to exclude thumbs.db from it. All archives support an exclude flag.
I hope this helps.
I am trying to create an IPA file from Bamboo by doing this: Firstly I will checkout the default repository, then clone a devops repository, then have a nuget restore task. All of these tasks work perfectly fine but it is the Build for iOS task which is where I create my .IPA file is were I am having the problems. Firstly I am using a command task and the files are being build on a mac-agent(needed to create the .IPA file).
I have tried this two different ways, both ways have different outcomes but basically it is not what I expect to happen. The first way I tried was to use mdtool as the executable which worked like this:
-v build -t:build -p:CustomerApp.iOS *-c:Release|iPhone* CustomerApp.sln
This task will build but the .IPA file will not be created and the log file just says Build for iOS succeeded so I do not know what the problem is for that. The second way that I tried was to use xbuild as the executable which I did it like this:
xbuild /p:Configuration=AppStore /p:Platform=iPhone /p:BuildIpa=true /target:Build CustomerApp.sln
And also tried changing the /p:Configuration=AppStore to /p:Configuration=Release
But both of these responses will return the error
MSBUILD: error MSBUILD0004: Too many project files specified
Note that I know it says error MSBUILD0004 but I am not calling the error the xbuild executable is called with the path: /usr/local/bin/xbuild likewise the mdtool is being called successfully through the path: /Applications/Xamarin Studio.app/Conents/MacOS/mdtool and I have checked that the files exist through the terminal.
What is the reason that the mdtool and xbuild will not create the .IPA file? From what I have seen online it was mainly to do with applications that were not up to date but mine are as shown by the log here:
Already up-to-date.
MSBuild auto-detection: using msbuild version '4.0' from '/usr/local/Cellar/mono/4.6.2.7/lib/mono/4.5'.
All packages listed in packages.config are already installed.
Bamboo is creating a folder which is called MOB-CUSAPP9-JOB1. This is where I want to generate the IPA file from but using that still gives me the error above when using the xbuild way, inside the folder when it is generated it has a file called the CustomerApp.sln which I also tried but got the error as well. Inside the MOB-CUSAPP9-JOB1 files that get created are Mobile.Core.iOS and CustomerApp.iOS I have tried to use all of these and get the same error, I have even tried the whole directory to this but /users/dev/bamboo/etc/MOB-CUSAPP9-JOB1 but got the same result.
Here is an image of the folder that bamboo builds:
I seem to be getting a lot of pain with the processing of app.config and token files (we have this working with the older ".11" templates).
It looks like currently (using the ReleaseTfvcTemplate.12.xaml) this is running the tokenisation after the build.
While I can make the app.config / myapp.exe.config stuff work by deliberately copying the .token file into my output folder (so the recursive search finds it) this feels pretty horrid.
As a fix I'm tempted to move lines 182-230 to just before the RunMSBuild task on line 175 (creating a new sequence at that point)
Is this the correct approach or have I missed some documentation somewhere (or a later version of the template?)
Thanks guys... Anyway for future reference I did make the change.
However I had misunderstood the exact nature of the order things happen out of the box which is as follows:
Get the project out of source control
build with msbuild
Copy the .config.token file over the .config file. This is in the TFS template
As part of the deploy to a server then the token entries in the .config files are replaced. This is in the release manager template.
Tests are run in the msbuild binary output folders.
The problem is this doesn't really work if you're using an project type that uses app.config file as the msbuild process renames these output.exe.config during the msbuild stage so you need to create both an output.exe.config (marked as copy to output) and an output.exe.config.token so when the post deploy is the final output gets configured correctly. This also a problem if you want to tokenise some mstest dlls as these typically use an app.config as well. Basically this is a bit of a mess unless you are using web.config.
We worked our way around this by using the modification I suggested above (you need to create a sequence at line 175 and move lines 178-230 up into the sequence, this is GetBuildDirectory variable bits and the if statement) followed by adding an additional deployment stage which copies back onto the build server with the new tokenised files so the mstest can run against them.
So our new process looks like this:
Get the project out of source control
Copy the .config.token file over the .config file i.e app.config.token copied over app.config
build with msbuild (this means we end up with tokenised myapp.exe.config and mytests.dll.config)
As part of the deploy to a server then the token entries in the .config files are replaced. This is a release management step in the release template.
Deploy the tests back into a folder on build server (think this has to be a fixed folder until update 4 of release manager is deployed) the token entries in the .config files are replaced (so our integration tests can use the newly deployed servers). This is a release management step in the release template.
Tests are run in the fixed folder on the build server (rather than the msbuild output directory) so the test wildcard needs to be changed in the tfs build template.
Quick final note we don't use that build directory variable and it's left at blank I'm not convinced this would work if it was set to a value...
The replacement of variables in config files with Release Management happens at deployment time and not at compile time.
When RM deployes your app it inserts the correct variables.
It sounds like you're hitting one of two issues:
You need to include the .token file in your project and make sure it's set to Copy Always, so that it gets copied to the build output folder.
If you're building a web application, I've seen a bug in the release build process template that doesn't touch the contents of the _PublishedWebsites folder. I don't know if it's been fixed in Update 4 or not, but it was definitely still a problem in earlier versions.
I am trying to call TF get command via Team Build script. I am getting the following error
Unable to determine the workspace.
Folks over the internet tell that this error is because Team Build cannot find the workspace because it is being called from a directory which is not part of the workspace.
The solution presented is to specify the working directory. I do so. The mappings are ok in Build Definition path as well as in the workspace. But now i get the following error:
Could not find cmd.exe in the current
directory . The directory name is
invalid.
Kindly help.
Thanks
Solved the problem. I added one more binding in my build Definition Workspace Section and referenced files to get/checkin/checkout with the help of variable $(MSBuildSourceDirectory). Meanwhile I ensured that $(SourceDir) is used to specify mapping in the workspace section of my Build Definiton dialog.
(source: geekswithblogs.net)
At the same time i encountered 260-character path limit, so i modified the output directory in build path as described here
(source: geekswithblogs.net)