VS multitarget namespace not found?

In visual studio, I’ve created a project that’s .NET7, then changed the target to net48;net7.0-windows but when i try to compile, I’m getting a bunch of errors saying namespace name 'Grasshopper' not found, if I only target net48 it compiles fine.

I followed the instructions here:

in the video, they were able to compile while targeting both 4.8 and 7 without encountering this error? Any ideas why?

my csproj

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFrameworks>net48;net7.0-windows</TargetFrameworks>
	<LangVersion>11</LangVersion>
    <OutputType>Library</OutputType>
    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
    <AssemblyTitle>Test</AssemblyTitle>
    <Product>Test</Product>
    <Copyright>Copyright ©  2024</Copyright>
    <AssemblyVersion>0.1.0</AssemblyVersion>
    <FileVersion>0.1.0.0</FileVersion>
	<TargetExt>.gha</TargetExt>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Grasshopper" Version="7.28.23058.3001" />
  </ItemGroup>
  <ItemGroup>
    <Compile Update="Properties\Resources.Designer.cs">
      <DesignTime>True</DesignTime>
      <AutoGen>True</AutoGen>
      <DependentUpon>Resources.resx</DependentUpon>
    </Compile>
  </ItemGroup>
  <ItemGroup>
    <EmbeddedResource Update="Properties\Resources.resx">
      <Generator>ResXFileCodeGenerator</Generator>
      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
    </EmbeddedResource>
  </ItemGroup>
</Project>

The error:

Severity Code Description Project File Line Suppression State Details
Error CS0246 The type or namespace name ‘Grasshopper’ could not be found (are you missing a using directive or an assembly reference?) Test (net7.0-windows) D:\Repo\Test\src\GlobalUsing.cs 1 Active

@curtisw can you provide any insights on this?

@victorlin I’m not seeing the same issues. Perhaps something else it causing it?

Here is a sample project that works for me:

MyGrasshopperMultiTargetedPlugin.zip (3.0 KB)

1 Like

UPDATE:
Ok, I’ve found the issue, multitarget only work if I’m targeting grasshopper package 7.19 and higher.
Originally I was targeting 7.0, and I’d get the error.
Not sure why in the original post I have 7.28, maybe I updated, but didn’t press build, so the error list didn’t update,