nil4 / dotnet-transform-xdt

Modern .NET tools and library for XDT (Xml Document Transformation)
Apache License 2.0
118 stars 12 forks source link

Simplifications for samples #7

Closed guardrex closed 7 years ago

guardrex commented 7 years ago

It seems to work ok without " paths and with a _TargetWebConfig aimed at the $(PublishDir), which seems like it would simplify samples a bit (unless it's gonna :boom: otherwise).

<Target Name="RemoveHandlersFromWebConfig" AfterTargets="_WebConfigTransform">
  <PropertyGroup>
    <_SourceWebConfig>$(PublishDir)web.config</_SourceWebConfig>
    <_XdtTransform>$(MSBuildThisFileDirectory)web.RemoveHandlers.config</_XdtTransform>
    <_TargetWebConfig>$(PublishDir)web.config</_TargetWebConfig>
  </PropertyGroup>
  <Exec Command="dotnet transform-xdt --xml $(_SourceWebConfig) --transform $(_XdtTransform) --output $(_TargetWebConfig)" Condition="Exists('$(_XdtTransform)')" />
</Target>

... you may want the capitalized "W" tho in web.config. I keep mine lowercase, but I am aware of the tradition of using Web.config in projects out there. [Kind'a strange sometimes which conventions the .NET Core team kept and which ones they changed, since IIS.net is full of upper-case "W" Web.config mentions.]

[EDIT] Is the &quot; path thing to cover spaces in paths?

nil4 commented 7 years ago

Yup, the &quot; bit is for spaces and unfortunately must stay, although I agree it complicates the samples.

Let me try <_TargetWebConfig>$(PublishDir)web.config</_TargetWebConfig>; the MSBuild gobbledygook I use now was mostly due to differences between what gets passed via dotnet publish (relative path) and publishing inside VS (absolute path to somewhere under obj\PublishTmp). If $(PublishDir) works for both, we're golden.

Good feedback on consistency of naming, I will update to Web.config everywhere; I just wish dotnet new -t web would use the same 😉. Otherwise, sooner or later a Linux or Mac user will come calling.

guardrex commented 7 years ago

Ok ... I thought so on the path thing. Since all of my paths are always no spaces, I'll be good for my own use of this to go no-&quot; for aesthetics.

You can see how well I've been trained ... or :fire: burned :fire: :smile: ... on spaces in paths over the years. I never use spaces in paths for app dev paths or in filenames. I live a lot happier :smile: this way.

guardrex commented 7 years ago

Cool. I'll leave this for you to close then. I'm good on my questions. Paths with spaces peeps need to use &quot; ... Peeps :ghost: afraid :ghost: of spaces in paths who never do that sort of thing, can drop the &quot;.

nil4 commented 7 years ago

You were spot on about $(PublishDir), thanks! I just updated the samples with the much cleaner property: https://github.com/nil4/xdt-samples/commit/2877962a02e2e0be41972134e68434dc1e1acce6