nil4 / dotnet-transform-xdt

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Version for package `Microsoft.Dotnet.Xdt.Tools` could not be resolved.

Grompot77 opened this issue · comments

Hi

Since adding the dotnet 2.2 SDK, I am unable to run the dotnet transform-xdt commands. All that I am getting is
Version for package Microsoft.Dotnet.Xdt.Tools could not be resolved.

I do have the following:
<ItemGroup> <DotNetCliToolReference Include="Microsoft.Dotnet.Xdt.Tools" Version="2.0.0" /> </ItemGroup>
And have the following as a build requirement:

<PropertyGroup>
<_SourceConfig>$(MSBuildThisFileDirectory)nlogbase.config</_SourceConfig>
<_XdtTransform>$(MSBuildThisFileDirectory)nlogbase.$(Configuration).config</_XdtTransform>
<_TargetConfig>$(TargetDir)nlog.config</_TargetConfig>
</PropertyGroup>
<Exec Command="dotnet transform-xdt --verbose --xml &quot;$(_SourceConfig)&quot; --transform &quot;$(_XdtTransform)&quot; --output &quot;$(_TargetConfig)&quot;" />
</Target>

It works 100% when I uninstall 2.2 SDK

Apart from the web.*.config that has to be transformed, we create nlog.config files per environment using the transformation tool.

Any corrective measures that can be done?

commented

Does it help if you run dotnet restore explicitly before building? Perhaps try deleting the obj folders in your project/solution before running dotnet restore.

If that does not help, please run dotnet nuget locals all --clear then dotnet restore again.

It is usually a good idea to always force a restore explicitly when changing the installed .NET Core version.

I tried to reproduce this with .NET Core 2.2.202 (as output by dotnet --version) but I wasn't able to.

If none of the above works for you, can you try your repro on one of the projects in my simple XDT samples repo, and share your dotnet --version output, and the results your are seeing?

i will have a look again, i did:

  1. clear the local caches before the obj directory.
  2. force a package restore
  3. build and still failed

only when uninstalling the netcore 2.0 sdk's it worked again

for now here is my version
C:>dotnet --version
2.2.202

Thank you for the response, i have now done it purely from the command line and all worked.
[XDT] Transforming 'nlogbase.config' using 'nlogbase.debug.config' into 'bin\debug\netcoreapp2.1\nlog.config'

Another question, is it still compatible if we look at netcore 3.0 previews ... i can not see why it should not work

commented

@Grompot77 glad to hear that it worked from the command line in the end! That's the result I was seeing as well.

I believe the tool should remain compatible with 3.x, but I have not explicitly tested that scenario yet; I am waiting for an RC or final version to be available.

Given the announcement at dotnet/announcements#107, I would expect this tool to continue working, because it already matches the emphasized part below:

.NET Core 3 takes the next step in the .NET Core tool strategy with local tools. As part of this process, starting in Preview 4 DotNetCliToolReference tools will be restricted to targeting .NET Core 2.2 and below. DotNetCliToolReference tools can be used in projects targeting .NET Core 3.0, but the tools themselves should target .NET Core 2.2 or below.

just ran it from the command line with 3.0.100-preview5-011568 SDK on the existing project targeting 2.1.3 LTS, that worked as well

commented

@Grompot77 that's very good to hear, thanks a lot for trying it out!