Loosing environment variables in .cproject in Eclipse Oxygen - environment-variables

I have some Yocto recipes running that clean out my source directories before building. The problem is that I also have an Eclipse CDT project defined in the same source directory that gets deleted when I do the clean. I modified my scripts so that the .project and .cproject files would get copied to a safe location and then copied back once the build is complete. Everything appears to get restored satisfactorily except for the environment variables defined in the Project's Build Configurations (right-click Project->Properties->C/C++ Build->Environment). They get lost.
Now, I can see the environment variables defined in the org.eclipse... directory but it appears that they are time stamped somehow and are out of sync with the Project. How can I get the Project's Build Configurations to restore automatically? (it is a pain to have to redefined these variables everytime I do a clean/build).

Found the problem. There is a directory called .settings that appears along side the .project and .cproject files that also needs to be saved and then restored. When this is done the environment variables define under the project are also restored.

Related

How does TFS determine what directory to use for the output from a build?

I'm setting up some TFS build definitions. I see that once I run a build, the work is done within a subfolder of a subdirectory of /Agent/_work. It appears that the subfolder is the same between different executions of the same build definition, but I see no way to know in advance where I should expect TFS to set its working directory, nor do I see any way of specifying the name of the directory manually.
How does TFS determine what directory to use for the output from a build?
Refer to the documentation on build variables. The base folder can be accessed via the $(Agent.BuildDirectory) variable. The source folder is $(Build.SourcesDirectory).
You can't set this. It's determined by the agent's configuration.

Build vNext CodedUI Item Deployment - items specified in .testsettings not being copied

I have a CodedUI test suite. I'm attempting to use a B-D-T workflow in TFS 2015 R2 to deploy the test .dlls to a machine group and execute them.
The tests rely on a couple files - an html start page and an XML file.
First, I attempted to have the tests just run from the bin folder OR where they're deployed onto the machines in the machine group. No suggestions I found on SO or on the first 3 pages of google worked. Whenever I ran a test locally it would copy the test dlls to the TestResults folder and execute from there.
Then, I attempted to use a .testsettings file to deploy the files with the .dlls into the TestResults folder. I still truly don't understand why this is the best or only solution - if I can just execute from the Bin please let me know how, but it does work - locally.
Now in TFS 2015 when I deploy my testing software to the test agent(Member of the machine group), I can see my supporting files exactly where they should be in the test drop location. Then, the test starts. A temp folder is created in a byzantine region of AppData, where only the .dlls and config are copied - not the files specified in the .testsettings file! The testsettings file is specified in the "Run Functional Tests" task, which I reached by browsing to the correct file in source control.
I can provide any information you require. This should be so simple but it has been an enormous headache.
In the configuration you need to setup where you copied the files to on the remote machine using a "Windows Machine File Copy" task executed by the agent. You need to make sure all the files needed to run are copied to the server.
Then in your .testsettings file specify which of the files you copied over you want to deploy to the temporary test context directory. Only files already copied to the test agent can be selected here.
The File copy task would look something like:

Custom TFS Build Log Files

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.

Release manager for TFS 2013 app.config processing with token files

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.

TFS Build Issue with Typescript and Web Deploy

I have a strange issue where one of my builds is failing to create the web deployment package that other similar builds are creating. I am running TFS 2013.2 and all my clients are VS2013.2. Build server is also TFS 2013.2. The web application is .NET 4.5.1.
The purpose of the solution is to build and deploy two web applications using web deploy (publish profiles). The first applications compiles and deploys just fine. The second one fails very strangely.
The gist of what I think is going on is that the build service is copying source files to a temporary location to be zipped up. Here's a chunk from the log:
CopyAllFilesToSingleFolderForPackage:
Creating directory "obj\Development\Package\PackageTmp".
Copying all files to temporary location below for package/publish:
obj\Development\Package\PackageTmp.
Copying Scripts\path\production\Constants.js to obj\Development\Package\PackageTmp\Scripts\path\production\Constants.js.
Copying Scripts\path\production\Directives.js to obj\Development\Package\PackageTmp\Scripts\path\production\Directives.js.
Copying Scripts\path\production\ProductModule.js to obj\Development\Package\PackageTmp\Scripts\path\production\ProductModule.js.
Copying Scripts\path\production\Controllers.js to obj\Development\Package\PackageTmp\Scripts\path\production\Controllers.js.
Copying Scripts\path\production\Models.js to obj\Development\Package\PackageTmp\Scripts\path\production\Models.js.
Copying Scripts\path\production\Services.js to obj\Development\Package\PackageTmp\Scripts\path\production\Services.js.
Copying Scripts\path\path3\path3Controller.js to obj\Development\Package\PackageTmp\Scripts\path\path3\path3Controller.js.
Copying Scripts\path\path3\path3Module.js to obj\Development\Package\PackageTmp\Scripts\path\path3\path3Module.js.
Copying Scripts\path\path3\Directives.js to obj\Development\Package\PackageTmp\Scripts\path\path3\Directives.js.
Copying Scripts\path\path3\Filters.js to obj\Development\Package\PackageTmp\Scripts\path\path3\Filters.js.
Copying Scripts\path\path3\DetailController.js to obj\Development\Package\PackageTmp\Scripts\path\path3\DetailController.js.
Copying Scripts\path\path3\ListController.js to obj\Development\Package\PackageTmp\Scripts\path\path3\ListController.js.
Copying Scripts\path\path3\Models.js to obj\Development\Package\PackageTmp\Scripts\path\path3\Models.js.
Copying Scripts\path\path3\Services.js to obj\Development\Package\PackageTmp\Scripts\path\path3\Services.js.
CleanWebsitesWPPAllFilesInSingleFolder:
Removing directory "obj\Development\Package\PackageTmp".
You can see it's copying from the source to some temporary directory. Directly after, it completes removes that directory for whatever reason.
Then, it runs through a number of other actions such as
ValidateGlobalPackageSetting
CollectFilesFromIntermediateAssembly
CollectFilesFromContent
CollectFilesFromIntermediateSatelliteAssembliesWithTargetPath
CollectFilesFromReference
CollectFilesFromAllExtraReferenceFiles
CollectFilesFrom_binDeployableAssemblies
PipelineCollectFilesPhase
PreTransformWebConfig
TransformWebConfigCore
PostTransformWebConfig
PreProfileTransformWebConfig
PipelineTransformPhase
GetMSDeployInstalledVersionPath
ProcessPublishDatabaseSettings
PreAutoParameterizationWebConfigConnectionStrings
AutoParameterizationWebConfigConnectionStringsCore
PostAutoParameterizationWebConfigConnectionStrings
PipelineMsdeploySpecificTransformPhase
GenerateGlobalPublishSetting
Then we get to where it appears to want to create teh publish package for real this time
CopyAllFilesToSingleFolderForMsdeploy
Creating directory "obj\Development\Package\PackageTmp".
Copying all files to temporary location below for package/publish:
obj\Development\Package\PackageTmp.
Copying obj\Development\Package\PackageTmp\Scripts\path\path2\Constants.js to obj\Development\Package\PackageTmp\Scripts\path\path2\Constants.js.
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web\Microsoft.Web.Publishing.targets(2660,5): error : Copying file obj\Development\Package\PackageTmp\Scripts\path\path2\Constants.js to obj\Development\Package\PackageTmp\Scripts\path\path2\Constants.js failed. Could not find file 'obj\Development\Package\PackageTmp\Scripts\path\path2\Constants.js'. [D:\Builds\1\path.Web\Portal_Dev\Sources\Portal\Trunk\Code\path.Portal\path.Portal.Web\path.Portal.Web.csproj]
Done Building Project "D:\Builds\1\path.Web\Portal_Dev\Sources\Portal\Trunk\Code\path.Portal\path.Portal.Web\path.Portal.Web.csproj" (default targets) -- FAILED.
The strange part is that it's NOT copying from the source. It's attempting to copy from the temp location. First, the temp location has already been cleared. Second, that really doesn't make any sense at all to copy from obj\Package to onj\Package and not from Scripts\ to onj\Package
Here's the msdeploy argument that i'm using. It's working as is on several different builds.
/p:DeployOnBuild=true;PublishProfile=Development;DeployTarget=MSDeployPublish;MSDeployPublishMethod=RemoteAgent;MsDeployServiceUrl=http://someServer:9090;SkipExtraFilesOnServer=true;username=
My build template is a bit old, but I'm not having issues with any other builds or deployments.
I know there's probably more stuff I should provide. Please let me know what else I can add to help trouble shoot
EDIT: I mention typescript in the title. All of the files it's trying to copy are JS files generating from Typescript. They all have their build action set properly. The other we application project in this solution has no typescript at all and builds and deploys fine.
Also it's worth mentioning that if I manually publish from visual studio using the profile specified in my command line arguments, everything deploys just fine.
I changed build templates to the newest template and it worked. I lost all my customizations, but that points to my build template causing the problem

Resources