daveaglick / Scripty

Tools to let you use Roslyn-powered C# scripts for code generation
MIT License
621 stars 69 forks source link

Support for custom properties #102

Closed ManniManfred closed 7 years ago

ManniManfred commented 7 years ago

With this changes it is possible to add custom properties in ScriptyTask und use that in script. Example: <ScriptyTask ProjectFilePath="$(MSBuildProjectFullPath)" SolutionFilePath="$(SolutionPath)" ScriptyExecutable="$(ScriptyExecutable)" ScriptFiles="@(ScriptyFile)" ContinueOnError="$(ScriptyContinueOnError)" CustomProperties="ImgSettingsPath=$(ImgSettingsPath)" CustomReferences="$(MSBuildProjectDirectory)\$(LibsDir)\Lib.dll">

  <Output TaskParameter="CompileFiles" ItemName="CompileFiles" />
  <Output TaskParameter="ContentFiles" ItemName="ContentFiles" />
  <Output TaskParameter="EmbeddedResourceFiles" ItemName="EmbeddedResourceFiles" />
</ScriptyTask>

In Script you can access the property "ImgSettingsPath" with: Context.Project.CustomProperties["ImgSettingsPath"]

8

daveaglick commented 7 years ago

Thanks! It'll probably be a little while longer until I have a chance to come back here and merge PRs, do a release, etc. I'll be sure to get this one in my next round up updates.

daveaglick commented 7 years ago

Thanks a lot for this contribution, sorry it took so long to bring in!