devlooped / nugetizer

A simple to understand packing model for authoring NuGet packages
https://clarius.org/nugetizer/
MIT License
254 stars 7 forks source link

Empty TargetFramework breaks the build #416

Closed hankovich closed 12 months ago

hankovich commented 1 year ago

I have the following content in my csproj

<PropertyGroup>
  <TargetFramework /> <!-- used to override the default value specified in Directory.Build.props -->
  <TargetFrameworks>netstandard2.0;net8.0</TargetFrameworks>
</PropertyGroup>

And the build is broken

10>------ Build started: Project: Extensions, Configuration: Debug Any CPU ------
10>C:\.nuget\packages\nugetizer\1.0.5\buildMultiTargeting\NuGetizer.targets(14,3): error MSB4020: The value "" of the "Project" attribute in element <Import> is invalid.
10>Done building project "Extensions.csproj" -- FAILED.

If I'll remove <TargetFramework /> then everything will work as expected. As being said, it's needed to override the default value that comes from Directory.Build.props.

BTW calling nugetize from the command line shows another error NuGetizer.targets(14,3): error MSB4020: ╨╖╨╜╨░╤З╨╡╨╜╨╕╨╡ "" ╨░╤В╤А╨╕╨▒╤Г╤В╨░ "Project" ╨▓ ╤Н╨╗╨╡╨╝╨╡╨╜╤В╨╡ <Import> ╨╜╨╡╨┤╨╛╨┐╤Г╤Б╤В╨╕╨╝╨╛., so it looks like errors in russian are not displayed correctly.

kzu commented 1 year ago

I can't repro this. The library:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <PackageId>ClassLibrary</PackageId>
    <PackOnBuild>true</PackOnBuild>

    <TargetFramework />
    <TargetFrameworks>netstandard2.0;net8.0</TargetFrameworks>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="NuGetizer" Version="1.1.0" />
  </ItemGroup>

</Project>

The clearing of TF seems to breaking other things in VS, even if I remove nugetizer:

1>------ Rebuild All started: Project: ClassLibrary6, Configuration: Debug Any CPU ------
Restored C:\Delete\ClassLibrary6\ClassLibrary6\ClassLibrary6.csproj (in 16 ms).
1>C:\Program Files\dotnet\sdk\8.0.100-preview.6.23330.14\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(314,5): message NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy
1>C:\Program Files\dotnet\sdk\8.0.100-preview.6.23330.14\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(314,5): message NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy
1>C:\Program Files\dotnet\sdk\8.0.100-preview.6.23330.14\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(266,5): error NETSDK1005: Assets file 'C:\Delete\ClassLibrary6\ClassLibrary6\obj\project.assets.json' doesn't have a target for 'net8.0'. Ensure that restore has run and that you have included 'net8.0' in the TargetFrameworks for your project.
1>Done building project "ClassLibrary6.csproj" -- FAILED.

From cmdline it works though.

Perhaps this was a fluke in the editor?

Also, the russian error message is not from nugetizer but MSBuild itself (messages with codes starting with MSB are built-in ones).

kzu commented 12 months ago

Closing for now since I couldn't repro. Please reopen if you can provide a reliable (and ideally isolated) repro.

Thanks!