microsoft / XmlNotepad

XML Notepad provides a simple intuitive User Interface for browsing and editing XML documents.
https://microsoft.github.io/XmlNotepad/
MIT License
966 stars 206 forks source link

'Newtonsoft' could not be found for \Application.csproj #384

Open NSP-0123456 opened 2 months ago

NSP-0123456 commented 2 months ago

Compilation issue from fresh repo clone. did a nuget restore before. I'm trying to compile xml notepad in windows 11 with Visual Studio 2022 v17.9.6. I get an error : error CS0246: The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?) [C:\dev\DevPerso\XmlNotepad\src\Application\Application.csproj]

Newtonsoft.json is in the package folder but compilation fails.

lovettchris commented 2 months ago

It is not entirely a dotnet core solution, so you have to do this:

nuget  restore xmlnotepad.sln
echo namespace XmlNotepad { public partial class AppAnalytics { private const string ApiKey="%XMLNOTEPAD_ANALYTICSKEY%"; } } > src\model\ApiKey.cs
msbuild xmlnotepad.sln

I added this to the build instructions.

NSP-0123456 commented 2 months ago

Working fine in debug, but still fails in release and just using build.cmd

lovettchris commented 2 months ago

Try loading C:\dev\DevPerso\XmlNotepad\src\XmlNotepad.sln in Visual Studio 2022 and select Release/Any CPU build configuration then select "Build/Rebuild" option. Rebuild should restore all missing packages.

NSP-0123456 commented 2 months ago

It is exactly what is not working. even on your build script debug is OK release fails.

lovettchris commented 2 months ago

Hmmm, can check you can access https://www.nuget.org/packages/Newtonsoft.Json/13.0.3 ?

If so, please run git clean -dfx in the root of your XmlNotepad repo and nuget locals all -clear to force nuget to download the packages again, then turn on msbuild diagnostic verbosity:

image

this select the "Rebuild" option and send me the verbose build output? my electronic mail alias at microsoft is clovett.

lovettchris commented 2 months ago

Also if you run this:

nuget search Newtonsoft.json

Does it show

====================
Source: nuget.org
--------------------
> Newtonsoft.Json | 13.0.3 | Downloads: 4,627,283,248
  Json.NET is a popular high-performance JSON framework for .NET

? You might have a corporate environment that is limiting which packages you can use...