clariuslabs / TransformOnBuild

Transform Text Templates On Build
Apache License 2.0
48 stars 17 forks source link

Add support for finding TextTransform in Visual Studio 2019 #61

Open rsheptolut opened 5 years ago

rsheptolut commented 5 years ago

I was working in VS2019 installed side by side with VS2017 and everything woked fine. Decided today that I won't be needing VS2017 anymore, and sure enough Clarius.TransformOnBuild stopped working for me. My guess is it doesn't know where to find TextTransform.exe. The error I'm getting is pretty cryptic, though: CS1056 Compiling transformation: Unexpected character '$'. So can be useful to also improve error messaging.

I haven't made any changes to the T4 file I'm transforming and the file transforms fine by the means of the VS2019 itself (when saving the T4 file for example). I did update Visual Studio 2019 to 16.0.4 though.

rsheptolut commented 5 years ago

Quick fix for those with only VS2019 on their PC: just copy C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE to C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE.

jon49 commented 5 years ago

Looks like this issue is easily fixed with about 4 lines of code. I'm just evaluating this lib so I won't create a pull request until I know I really want to use it!

https://github.com/clariuslabs/TransformOnBuild/blob/4948e36ea6d67cbf864b8f45adcc37136519f0ca/Clarius.TransformOnBuild.MSBuild.Task/Clarius.TransformOnBuild.MSBuild.Task/TransformOnBuildTask.cs#L150

thomassuckow commented 4 years ago

Would be interesting to see a port to t5 instead, would make it even more portable

jgomesmv commented 4 years ago

I'm also facing the same issue :D

rsheptolut commented 4 years ago

A good workaround is to add this to your csproj file in one of the existing property groups there (or add a new one, without conditions):

<TextTransformPath>$(DevEnvDir)\TextTransform.exe</TextTransformPath>
jgomesmv commented 4 years ago

@rsheptolut it works like a charm! Thanks for your help! It saved me the need to install vs 2017 :D

johnverbiest commented 2 years ago

Hi,

In case you are still waiting for this (or arriving here by accident). I created a fork of this project and have build and deployed the correct nuget package that includes the change for VS2019. You can find the nuget package on https://www.nuget.org/packages/JohnVerbiest.TransformOnBuild/.

I will be accepting pull requests in hope to put some new life into this.