0

The Microsoft Slowcheetah website states

This package allows you to automatically transform your app.config (or any file) when you press F5 in Visual Studio.

I have a SQL Server VS solution which requires configuration dependent users and logins. Slowcheetah would be a good solution if I can figure out what the transform file should look like.

For example I would like the statement

CREATE LOGIN [DEVDOMAIN\ReadonlyUser] FROM WINDOWS DEFAULT_DATABASE = MyDb_Dev;

Transformed to

CREATE LOGIN [TESTDOMAIN\ReadonlyUser] FROM WINDOWS DEFAULT_DATABASE = MyDb_Uat;

Is this achievable?

Hugh Jones
  • 2,706
  • 19
  • 30
  • 1
    Where did you see the "any file" quote exactly? https://github.com/microsoft/slow-cheetah#supported-file-types suggests it only supports XML and JSON files – ADyson Aug 01 '19 at 08:58
  • @ADyson [SlowCheetah - Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=vscps.SlowCheetah-XMLTransforms) says *This package allows you to automatically transform your app.config (or any file) when you press F5 in Visual Studio.* – AlwaysLearning Aug 01 '19 at 09:01
  • @AlwaysLearning hmm, looks like a bit of poor wording to me. The strapline part also says "Transform xml and json files at build time". All the examples given relate to config files as well. – ADyson Aug 01 '19 at 09:03
  • I edited my post to include a link – Hugh Jones Aug 01 '19 at 09:03
  • @HughJones are you hoping to transform SQL scripts? Or just some associated XML/JSON config files? It would be good to have an example of the input, and the required output. – ADyson Aug 01 '19 at 09:04
  • 1
    I'm thinking they meant to say "(or any XML file)". – AlwaysLearning Aug 01 '19 at 09:05
  • @ADyson - yes .sql scripts. My use case is CREATE USER and CREATE LOGIN scripts; AD User accounts are needed for develop, test, uat and production builds and in our environment the domains are separated. I would also need a postdeployment script to add the appropriate user to a role. – Hugh Jones Aug 01 '19 at 14:54

2 Answers2

0

SlowCheetah currently only supports using XML Document Transforms on XML files or JSON Document Transforms on JSON files.

If you can get your user data into one of those format you'll be set, otherwise...

AlwaysLearning
  • 7,915
  • 5
  • 27
  • 35
0

So it is not possible as far as anyone can tell. I also had no luck trying to get files to load into the projects according to which build configuration had been selected. This seems to be a feature of VS Sql Projects.

The solution I came up with in the end was to

i) Manually edit the .sqlproj (unload the project, right-click, select 'edit') adding in

<ItemGroup>
  <None include="dbo\Security\users\ReadonlyUser\DEV_Login.sql"  
  <None include="dbo\Security\users\ReadonlyUser\UAT_Login.sql"
  <!-- et cetera -->
</ItemGroup>

ii) add another itemgroup

<ItemGroup>
  <Build include="dbo\Security\users\ReadonlyUser_Login.sql"   
</ItemGroup>

iii) Reload the project and add a Build event (Pre-build event command line)

Copy $(ProjectDir)\dbo\Security\users\ReadonlyUser\$(Configuration)_Login.sql $(ProjectDir)\dbo\Security\users\ReadonlyUser_Login.sql
Hugh Jones
  • 2,706
  • 19
  • 30