Cannot get build agent to copy .config files for testing
New to use TeamCity, and been searching for a solution to my problem, but unable to find a solution.
I have created a project within TeamCity that has two build steps
Build Step 1 is to pull changes from source control and build solution
Build Step 2 is to run unit test project using MSTest.
I am having problem with build step 2
Within the solution, I have a configuration folder which contains environment specific config files.
eg
dev\castle.config
dev\appsettings.config
Several projects in the solution are linked to the config files, with the property "Copy to output directory" set to copy always.The test project within build step 2 has a link to file castle.config.
Whenever the project is run, build step 1 is successful, but build step 2 fails because the test runner cannot find castle.config in the temp folder where it appears the test solution is copied to
I then put in a build step on the test solution is visual studio to also copy across the files, but this has made no difference
.
This is one error, but all failing tests have the similar error about not being able to find castle.config
Exception message: System.TypeInitializationException: The type initializer for 'TrainingAssist.Services.Storage.Resolver' threw an exception. ---> System.Configuration.ConfigurationErrorsException:
Unable to open configSource file 'castle.config'. (C:\TeamCity\buildAgent\temp\buildTmp\SYSTEM_BUILDSERVER 2011-07-07 15_57_29\Out\Tests.DLL.config line 8)
at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult)
at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName)
at System.Configuration.ConfigurationManager.GetSection(String sectionName)
at Castle.Core.Resource.ConfigResource..ctor(String sectionName) in e:\OSS.Code\Castle.Core\src\Castle.Core\Core\Resource\ConfigResource.cs:line 44
at TrainingAssist.Services.Storage.Resolver..cctor() in c:\TeamCity\buildAgent\work\a045edf9fb4ccb04\code\app\services\Storage\Utils\Resolver.cs:line 20
--- End of inner exception stack trace ---
at TrainingAssist.Services.Storage.Resolver.Of[T]()
at TrainingAssist.Services.Storage.Service.Service..ctor(IStorageItemRepository storageItemRepository) in c:\TeamCity\buildAgent\work\a045edf9fb4ccb04\code\app\services\Storage\Service\Service.cs:line 79
at Tests.Service.Remove.Service_Remove_Throws_If_StorageKey_Key_Is_Empty_Guid() in c:\TeamCity\buildAgent\work\a045edf9fb4ccb04\code\app\services\Storage\Tests\Service\Remove.cs:line 97
What do I need to do so that when the build step is executed, all the relevant .config files are copies across, not just the tests.dll.config file.
This is what is configured in the build step
| Runner type: |
-- Choose build runner type -- .NET Process Runner Ant Command Line Duplicates finder (.NET) Duplicates finder (Java) FxCop Gradle Inspections IntelliJ IDEA Project Ipr (obsolete runner) Maven MSBuild MSpec MSTest NAnt NUnit Powershell Rake Visual Studio (sln) Visual Studio 2003 |
|---|---|
| Step name: | You can specify build step name to distinguish it from other steps. |
| Path to MSTest.exe: |
Enter the path to MSTest.exe. Use %system.MSTest.8.0%, %system.MSTest.9.0% or %system.MSTest.10.0% to refer to build agent auto-detected MSTest.exe. |
| List assembly files: | Enter newline-separated list of assemblies. Each assembly will be passed in the separate /testcontainer:file commandline argument |
| MSTest run configuration file: |
Enter MSTest configuration file. /runconfig:file commandline argument is used |
| MSTest metadata: |
Enter a value for /testmetadata: argument |
| Testlist from metadata to run | Every line will be translated into /testlist:line argument. |
| Test: | Add /unique commandline argument |
| Results file: |
Enter a value for /resultsfile:file commandline argument. |
| Additional commandline parameters: |
Enter an additional commandline parameters for MSTest.exe |
| .NET Coverage | |
| .NET Coverage tool: |
<No .NET Coverage> JetBrains dotCover NCover (1.x) NCover (3.x) PartCover (2.2 or 2.3) Choose a .NET coverage tool. |
Please sign in to leave a comment.
Find checkout directory under c:\TeamCity\buildAgent\work\ and try to run MSBuild interactivelly from there. Is the error reproduced?
Also, there is no need to configure VCS interaction within a build step. TeamCity allows to set up VCS-related settings right in build configuration UI. Such way you can monitor VCS for changes, trigger builds automatically, and see changes build history.