kniEngine / kni

KNI is a cross-platform C# game framework.
Other
98 stars 5 forks source link

Missing targets file #681

Closed davidhesselbom closed 1 month ago

davidhesselbom commented 8 months ago

After installing the SDK and creating a new project from template in VS2022, the project builds and runs, but I still get the following error in Visual Studio:

"C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\MonoGame\v3.0\MonoGame.Content.Builder17.targets" was not imported by "C:\Users\david\source\repos\KniGame2\KniGame2\KniGame2.csproj" at (40,3), due to the file not existing.

The same error is issued when building with dotnet publish, which aborts upon the error, however the command msbuild completes without errors.

The requested file is missing on my machine, indeed even the Microsoft Visual Studio\2022\Community\MSBuild folder does not exist. But again, the project still builds and runs, so why the error?

nkast commented 8 months ago

That's is an issue I've seen as well in VS2022. the import and $(MSBuildExtensionsPath) are not resolved correctly if the build fails for other reasons. Check for other errors/issues with your build. Once you resolve them, this error will go away.

davidhesselbom commented 8 months ago

But the build doesn't fail, the build completes and the game starts. I get this error even when building immediately after creating a new project from the KNI template and not changing anything. And I don't see any other errors, just this one. Where do you suggest looking for errors/issues other than the "Build Output" and "Error List" in Visual Studio?

Beliar83 commented 4 months ago

I got the same error, but for "Kni.Content.Builder.targets". I found the file in "C:\Program Files (x86)\MSBuild\MonoGame\v3.0", but the msbuild called from Rider (which is also the one called from dotnet build) seems to look in "C:\Program Files\dotnet\sdk\8.0.101\MonoGame\v3.0" and the one called from Visual Studio 2022 in "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\MonoGame\v3.0" It seems they can't agree where "MSBuildExtensionsPath" is.

nkast commented 4 months ago

I am working on an alternative solution. Here's how you can test it:

1) open your .csproj 2) Remove this line at the end

  <Import Project="$(MSBuildExtensionsPath)\MonoGame\v3.0\Kni.Content.Builder.targets" />

3) Add this nuget package:

  <ItemGroup>
    <PackageReference Include="nkast.Xna.Framework.Content.Pipeline.Builder" Version="3.10.9001-rc" />
  </ItemGroup>

4) Save the .csproj and restore the packages (a rebuild from VS will do.)

The package is 34MB , it might take a while to restore the project the first time.

Beliar83 commented 4 months ago

@nkast That seems to work

nkast commented 1 month ago

In v3.11 you can use <PackageReference Include="nkast.Xna.Framework.Content.Pipeline.Builder" Version="3.11.9001" /> as described above, or <PackageReference Include="nkast.Xna.Framework.Content.Pipeline.Builder.Windows" Version="3.11.9001" /> ,,, in case your importer/processor require a full graphics backend.

I consider this resolved... closing.