nil4 / dotnet-transform-xdt

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

Cannot Run with multiple *proj in same directory #33

Closed satbirbaidwan closed 6 years ago

satbirbaidwan commented 6 years ago

Hi, I have tested this in a new solution and it works fine. Thanks and great job. However when i tried to incorporate this in my actual solution i am getting error "Specify which project file to use because this c:\pathtofolder\project contains more than one project file."

I looked in the source folder and i have project.csproj project.csproj.user project.csproj.vspscc

This appears to be a known issue with CLI Tools Is there a way to get around this without deleting other files ?

nil4 commented 6 years ago

Thank you for your feedback, @satbirbaidwan!

I had a similar report in #14, but your case seems a bit different. There's only one actual project file (i.e. .csproj), while the others are a local settings file (.user) and some VS source control file.

The error message you are seeing, however, is not coming from this tool, as you already found out. The CLI issue (dotnet/cli#4808) is the root cause, and affects all custom dotnet tools, including this one. I don't know of a way around it, other than ensuring only one project file is present.

I encourage you to add your feedback on the CLI issue, since yours seems to be a case where the error message is not just inconvenient, but also incorrect. It would probably help if you can add a repository with a repro case to demonstrate the issue.

Perhaps that will remind the CLI team to revisit the issue and hopefully fix it; it's been open for a long time now.

nil4 commented 6 years ago

As there is nothing actionable that I can fix here, I will close this issue.

satbirbaidwan commented 6 years ago

Thanks for looking into this and replying!

I actually found a workaround. I installed transform-xdt as a global tool using dotnet tool install --global dotnet-xdt --version 2.1.0
as mentioned in your article

and all i had to do is change in xx.csproj file change line

`<Exec
    Command="dotnet transform-xdt --xml &quot;$(_SourceWebConfig)&quot; --transform &quot;$(_XdtTransform)&quot; --output &quot;$(_TargetWebConfig)&quot;"
    Condition="Exists('$(_XdtTransform)')" />

`

to

<Exec Command="dotnet xdt --xml &quot;$(_SourceWebConfig)&quot; --transform &quot;$(_XdtTransform)&quot; --output &quot;$(_TargetWebConfig)&quot;" Condition="Exists('$(_XdtTransform)')" />

and it works as expected

Regards, Satbir Baidwan