qetza / vsts-replacetokens-task

[ARCHIVED] Visual Studio Team Services Build and Release extension that replace tokens in files with variable values.. Project moved to https://github.com/qetza/replacetokens-task
MIT License
163 stars 56 forks source link

Approach for testing locally #10

Closed jsiegmund closed 8 years ago

jsiegmund commented 8 years ago

I was wondering what the recommended approach is for running tests locally? I've used your extension to set-up automated building in VSTS, but in some cases I like to be able to run the tests locally first just to check whether a problem was actually solved. With only the tokens in the config file now, I cannot run any tests. So I was thinking of doing some sort of Powershell script to do the same and run that as a post-build command, but I'm not sure whether that would interfere with my online build. Also, it would require me to store the token values somewhere again, getting back to the danger of accidentally checking in config files with senstive data.

Any tips on how to solve this in a good way?

qetza commented 8 years ago

Hi @jsiegmund, Usually what i do is that i don't tokenize the configuration file (web.config or app.config) but a configuration transformation file (web.release.config or app.release.config using XDT syntax).

So the default configuration file has all the needed config to run locally and during the deployment i replace token in the transformation file then use a powershell to call the Microsoft.Web.Xdt.dll to apply the transformation and update the final configuration file.

If you are using WebDeploy, the idea would be to tokenize your SetParameters.xml file and do the replace before calling WebDeploy.

Hope this helps.

jsiegmund commented 8 years ago

I fully understand, but this doesn't fly when you're talking public repo's. I don't want to check in any sensitive data but I also don't want to check-in a project without it's config file :)

qetza commented 8 years ago

If your data for local testing is sensitive then i would suggest than you do the replace locally using your own powershell script and a json file (or whatever file format you prefer) which contains your data for testing. Just make sure the file is marked as to be ignored from version control :) You can take the code from this task to have the basic for your script.

jsiegmund commented 8 years ago

Ok, thanks!