0

This is a follow-up to another question.

I have a migrated .NET framework project which I'm trying to package using msbuild -t:pack and the corresponding NuGet.Build.Tasks.Pack.

I have included all of my NuGet information in the *.csproj-file, like so:

    <TargetFramework>net48</TargetFramework> <!-- Error! -->
    <PackageId>Testcenter.RobotFramework</PackageId>
    <Version>1.0.0</Version>
    <Authors>Testcenter Team, Some person</Authors>
    <Company>Some company</Company>
    <PackageOutputPath>$(ProjectDir)</PackageOutputPath>
    <Description>A class library to implement a remote library interface conforming to RobotFramework.</Description>
    <Title>RobotFramework Remote-Library-Interface for C#</Title>
    <Copyright>Copyright (c) Some company 2022</Copyright>
    <RepositoryUrl>https://redacted-url.com/repos/testcenter.robotframework/browse</RepositoryUrl>
    <Product>Testcenter.RobotFramework</Product>
    <AssemblyVersion>1.0.0</AssemblyVersion>
    <FileVersion>1.0.0</FileVersion>

Due to an error I am unable to use the TargetFramework property, normally used in SDK-style projects.

How do I add that property or anything for that matter, so that NuGet recognizes that I target net48 and shows that information in the packaged project?

I was not able to find information about this in the target frameworks documentation, because it only speaks of SDK-style projects, and apparently I cannot use their attributes in the project. Also, I did not find a similar documentation meant for Non-SDK projects.

HackXIt
  • 422
  • 5
  • 17

1 Answers1

0

The correct syntax for non-SDK-style projects is:

<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
Good Night Nerd Pride
  • 8,245
  • 4
  • 49
  • 65
  • Where is that information written? – HackXIt Jan 16 '23 at 08:55
  • 1
    @HackXIt ‍♂️ they seem to have [no more documentation](https://learn.microsoft.com/en-us/search/?terms=TargetFrameworkVersion&scope=.NET) on this. – Good Night Nerd Pride Jan 16 '23 at 09:01
  • @HackXIt that syntax started in 2005, .NET Framework 2.0 when MSBuild was introduced, so you should memorize it sadly if the documentation lost in years. – Lex Li Jan 16 '23 at 09:50
  • I noticed it is added automatically upon creation of the project, so there's no need to worry about it. It is just confusing when there's new documentation. They should have added information about it in the migration guide. – HackXIt Jan 16 '23 at 09:53