nil4 / dotnet-transform-xdt

Modern .NET tools and library for XDT (Xml Document Transformation)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Does not work with latest msbuild tooling

Grinderofl opened this issue · comments

I'm running dotnet version 1.0.0-rc4-004771

Using

  <Target Name="ApplyXdtConfigTransform" BeforeTargets="_WebConfigTransform">
    <PropertyGroup>
      <_SourceWebConfig>$(MSBuildThisFileDirectory)Web.config</_SourceWebConfig>
      <_XdtTransform>$(MSBuildThisFileDirectory)Web.$(Configuration).config</_XdtTransform>
      <_TargetWebConfig>$(PublishDir)Web.config</_TargetWebConfig>
    </PropertyGroup>
    <Exec Command="dotnet transform-xdt --xml &quot;$(_SourceWebConfig)&quot; --transform &quot;$(_XdtTransform)&quot; --output &quot;$(_TargetWebConfig)&quot;" />
  </Target>
  

Transformations do not run on publish.

Trying to sub BeforeTargets="_WebConfigTransform" for AfterTargets="Build" and running dotnet build does not seem to actually do anything. I've tried doing the recommended process also on the sample projects and they do not work either.

commented

@Grinderofl thank you for reporting this issue. As stated in the readme file, the current instructions are based solely on CLI 1.0.0-preview4-004233. I have not tested newer versions in-depth yet.

I had a quick look at RC4-004771, and it seems that the SDK target was renamed from _WebConfigTransform to _TransformWebConfig. Could you please try updating to BeforeTargets="_TransformWebConfig" and let me know if that works for you?

It worked for me on a simple test project. If you can confirm it as well, I will update the instructions accordingly. Looking forward to your feedback.

commented

@Grinderofl this is what I had to change to get the xdt-samples working with RC4:

-<Target Name="ApplyXdtConfigTransform" BeforeTargets="_WebConfigTransform">
+<Target Name="ApplyXdtConfigTransform" BeforeTargets="_TransformWebConfig">
commented

@Grinderofl I closed this issue after verifying that the change above works with RC4. Please reopen if you find otherwise.