Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The dotnet-svcutil tool does not resolve the value of the TargetFramework property when it contains other MSBuild properties. #5427

Open
RuneH-MSFT opened this issue Feb 16, 2024 · 3 comments
Assignees
Labels

Comments

@RuneH-MSFT
Copy link

RuneH-MSFT commented Feb 16, 2024

Describe the bug
When using the dotnet-svcutil tool from a C# SDK-style project and the project has <TargetFramework>$(LibTargetFramework)</TargetFramework>, the dotnet-svcutil tool will fail with a message about $(LibTargetFramework) not being a supported target framework even though the LibTargetFramework property resolves to netstandard2.0.

The target framework '$(libtargetframework)' is not a supported .NET Core, .NET Standard, or a .NET Framework version. The minimum supported framework versions are as follows: netcoreapp1.0, netstandard1.3 and net4.5.

The command "dotnet tool run dotnet-svcutil "WSDL\Repro.wsdl" -tf "netstandard2.0" -n "*,Repro.Proxy.Generated" -o ".generated\ReproProxy.cs" -v Verbose" exited with code 2.

I am using dotnet-svcutil 2.1.0 when encountering this error. If I change the TargetFramework property in the project file to be netstandard2.0 rather than using a property, it works.

To Reproduce
Steps to reproduce the behavior:

  1. Create a C# SDK-style library project for .NET Standard 2.0.
  2. Add a Directory.Build.props file and defined a property: <LibTargetFramework>netstandard2.0</LibTargetFramework>
  3. Update the csproj to set: <TargetFramework>$(LibTargetFramework)</TargetFramework>
  4. Add a custom target to invoke the dotnet-svcutil tool before the Build target.

See attached TestDotNetSvcUtilLib_CSProj.zip.

Expected behavior
The TargetFramework property should be resolved correctly.

@imcarolwang
Copy link
Contributor

Thanks for raising the issue, @RuneH-MSFT. There are some bug fixes in the latest preview version of the tool, instead of using dotnet-svcutil 2.1.0, could you please give version 2.2.0-preview1.23462.5 a try?

@RuneH-MSFT
Copy link
Author

@imcarolwang - That 2.2.0-preview1.23462.5 version from August does not appear to have the same issue. From searching other issues it looks like an issue was previously reported on this and was resolved in 2.0.1. Since I encounter it on 2.1.0, Hong Li requested that I log a new issue for this to make sure it is fixed in a non-preview release, so we can start using the tool. I hope there will be a non-preview release with the fix made available soon.

@RuneH-MSFT
Copy link
Author

@imcarolwang - With the 2.2.0-preview1.23462.5 version I can get a bit further, but I run into another error also related to using a property as the target framework when the project has assembly references without a hint path like this:

  <ItemGroup>
    <Reference Include="System.ServiceModel" />
  </ItemGroup>

The dotnet-svcutil tool will fail with this error:

The project reference specification 'System.ServiceModel' does not have a file path.

The command "dotnet tool run dotnet-svcutil "WSDL\Repro.wsdl" -ntr -tf "net48" -n "*,Repro.Proxy.Generated" -o ".\Generated\ReproProxy.cs" -v Verbose" exited with code 2.

In this case I am using "net48" as the value of the LibTargetFramework property in Directory.Build.props. If I change the project to use "net48" directly as the value of the TargetFramework property, I do not get this error.

It seems like the same problem where it does not correctly resolve the TargetFramework value.

I have attached another repro project for this variation of the problem:
TestDotNetSvcUtilLib_CSProj_2024-02-20.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants