applyWhen not working?

Feb 22, 2012 at 8:10 PM
Edited Feb 22, 2012 at 9:02 PM

I have the following configuration

<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:cg="http://roblevine.co.uk/Namespaces/ConfigGen/1/0">
 
  <system.web>
    <!--  AUTHORIZATION  -->
    <authorization cg:applyWhen="$AuthorizationDenyUsers">
      <deny users="[%AuthorizationDenyUsers%]"/>
    </authorization>

and when I apply my spreadsheet to the template I get this (almost like its ignoring the namespace when parsing). Spreadsheet has '?' for AutorizationAllowUsers. Do I need another command line argument for this to work?

<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:cg="http://roblevine.co.uk/Namespaces/ConfigGen/1/0">
  <system.web>
    <!--  AUTHORIZATION  -->
    <authorization cg:applyWhen="$AuthorizationDenyUsers">
      <deny users="" />
    </authorization>

 
 
Coordinator
Feb 22, 2012 at 9:45 PM
Edited Feb 22, 2012 at 11:10 PM

There should be a trailing "/" at the end of the namespace

http://roblevine.co.uk/Namespaces/ConfigGen/1/0/

I think that is why it is being ignored.

Can you try adding that and let me know if it fixes the problem?

Thanks,

Rob

Feb 23, 2012 at 9:07 PM

No change.  I added the trailing / and got the same thing. 

Coordinator
Feb 23, 2012 at 10:09 PM
Edited Feb 23, 2012 at 10:35 PM

Which version of ConfigGen are you using?

Can you run it again with the -v switch and post the output?

I can't see anything wrong with what you've posted, and whatever the contents of your settings spreadsheet is, the cg:applyWhen attribute should be removed from the output. Very odd.

This is the exact template I am using for testing your problem:

 

<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:cg="http://roblevine.co.uk/Namespaces/ConfigGen/1/0/">
  <system.web>
    <!--  AUTHORIZATION  -->
    <authorization cg:applyWhen="$AuthorizationDenyUsers">
      <deny users="[%AuthorizationDenyUsers%]"/>
    </authorization>
  </system.web>
</configuration>

and these are the two outputs (one for each result of the condition):

 

<?xml version="1.0" encoding="utf-8"?><configuration>
  <system.web>
    <!--  AUTHORIZATION  -->
    <authorization>
      <deny users="true" />
    </authorization>
  </system.web>
</configuration>

 

AND

 

<?xml version="1.0" encoding="utf-8"?><configuration>
  <system.web>
    <!--  AUTHORIZATION  -->
    
  </system.web>
</configuration>

apart from the slightly awkward placement of the root element (which I will look into), this all looks good.

Mar 1, 2012 at 2:58 PM

Sorry for the late response.

I grabbed the newest version and that seemed to do the trick.  I'm not sure what the problem actually was, but I didn't make any changes to the template or the spreadsheet. 

Fantastic project by the way.  I'd be editing 24 seperate configuration files if it weren't for this. I integrated it to the post build events in VS and it generates perfect configurations every time I build.  Awesome!

Coordinator
Mar 1, 2012 at 3:35 PM

Thanks for the update - and I'm really glad to hear it is working, and that ConfigGen is making your life easier - that was always the plan!

Please do feel free to contact me or raise feature requests, bug reports, etc. All feedback and suggestions are very gratefully received.

Thanks,

Rob