New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use a sc.variable in a patch file to change the location of generated classes #27

Closed
thesoftwarejedi opened this Issue Nov 18, 2015 · 3 comments

Comments

Projects
None yet
2 participants
@thesoftwarejedi
Copy link

thesoftwarejedi commented Nov 18, 2015

I'm trying to use a variable defined in a dev patch file that allows the dev to specify the source root folder. We don't use the webroot as the source root. Unicorn let's me do this. With Synthesis it is passed along as a string.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <synthesis>
      <providers>
        <generatorParametersProvider type="Synthesis.Configuration.ConfigurationGeneratorParametersProvider, Synthesis">
          <ItemOutputPath>$(sourceRoot)/Website/Code/Synthesis/Synthesis.Model.Concrete.cs</ItemOutputPath>
          <InterfaceOutputPath>$(sourceRoot)/Website/Code/Synthesis/Synthesis.Model.cs</InterfaceOutputPath>
        </generatorParametersProvider>
      </providers>
    </synthesis>
  </sitecore>
</configuration> 
@kamsar

This comment has been minimized.

Copy link
Collaborator

kamsar commented Jun 4, 2016

This is caused because Sitecore does not expand variables in element bodies, only attributes.

For example,

<InterfaceOutputPath foo="$(sourceRoot)">hello</InterfaceOutputPath>

would resolve sourceRoot, whereas as you found

<InterfaceOutputPath>$(sourceRoot)\hello</InterfaceOutputPath>

will not expand. You can see expansion in the showconfig.aspx page - the variable is applied at the config provider level.

Unicorn gets it because you're injecting it on an attribute as opposed to a body.

Unfortunately without altering the configuration schema significantly and breaking backwards compatibility there is little I can do about this. It's Sitecore's rules that are being followed.

Now that said, since multiple configs are supported it would be fairly easy to alter the way the default config is registered and/or register your own config - which can expand whatever variables you like since at that point the registration is in C#.

@kamsar kamsar closed this Jun 4, 2016

@kamsar

This comment has been minimized.

Copy link
Collaborator

kamsar commented Jun 5, 2016

I decided to make a workaround anyway because you're probably not the last person to run into this issue.

See d96e114

Essentially you can use variables in a setting that is prepended to all configs' output paths.

This will be in the next release.

@kamsar

This comment has been minimized.

Copy link
Collaborator

kamsar commented Jun 21, 2016

Fixed in 8.2.1

@kamsar kamsar closed this Jun 21, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment