wixsharp icon indicating copy to clipboard operation
wixsharp copied to clipboard

Could not load file or assembly System.Text.Json on WixSharp Setup (WiX3)

Open veselinoWiktor opened this issue 1 year ago • 10 comments

I'm using Visual Studio 2019 Professional, I installed WixSharp Project Templates Extension, version 2.2.8. When I create WiXSharp Setup (WiX3) project, I change the TargetFramework to net48 in the .csproj file, then in the App.config file, I also change sku=".NETFramework,Version=v4.8". And then I get the following error: NETSDK1060 Error reading assets file: Error loading lock file '(Path to solution)\WiXSharp.Setup\obj\project.assets.json' : Could not load file or assembly 'System.Text.Json, Version=7.0.0.3, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.

veselinoWiktor avatar Sep 11 '24 07:09 veselinoWiktor

morning, i found bit older stackoverflow post https://stackoverflow.com/questions/59595684/how-do-i-fix-the-error-could-not-load-file-or-assembly-system-text-json. Do you also tried wix v4 template ? In my opinion MS dll System.Text.Json needs NET Framework 7 or bettter and NOT .NET Framework. best regards, Torchok

Torchok19081986 avatar Sep 11 '24 08:09 Torchok19081986

I tried everything from the stackoverflow post and nothing worked, I also tried with wix v4 template but I have the same error. I also forgot to mention that, before 4-5 days everything was working correctly and suddenly yesterday when I opened the solution it said that the project was unable to load. Then I tried to create a new project in the solution and I received this error image after which I went to the sdk folder and renamed the minimumMSBuildVersion. So the error in the photo stopped popping but now I have this error, which was not popping 4-5 days ago.

veselinoWiktor avatar Sep 11 '24 09:09 veselinoWiktor

seems problem mit SDK for visual studio. Do you have latest update for VS ? there is also https://dotnet.microsoft.com/en-us/download/visual-studio-sdks for VS SDKs. Maybe it helps. https://learn.microsoft.com/de-de/dotnet/core/porting/versioning-sdk-msbuild-vs for review of NET SDKs. I think, you have problem with VS itself. Try to install latest update, latest SDK and latest .NET Framework Runtime and Developer Kit.

you can also try to delete all stuff inside project /.vs folder. Sometime VS cache behaviour is not fully understandable. Another suggestion : delete .sln file for this project and try to open it with VS and save .sln File. Can you also open any sample of oleg from release folder if yes, then VS files are corrupt or missing. Export user settings and try to repair VS from Installer.

Torchok19081986 avatar Sep 11 '24 11:09 Torchok19081986

I tried everything, even repaired the Visual Studio. But I still have the same error with the version only for WixSharp templates. When I first started testing WixSharp 4-5 days before opening the issue I didn't have both the problems and I managed to create the template, build it and it created the .msi file. Is there any update that came out recently, that may be the reason?

veselinoWiktor avatar Sep 17 '24 10:09 veselinoWiktor

for the latest update, only @oleg-shilo can give feedback, if templates was updatet to newer version or .net framework. The Message shown, your msbuild it not suitable for template of wixsharp. Strangewise you can open any project of oleg from source or release folder. i found error https://learn.microsoft.com/en-us/answers/questions/1286834/visual-studio-2019-unable-to-load-one-project-due , for your description. do you use VS 2019 or VS 2022 ? On Stackoverflow : https://stackoverflow.com/questions/74847918/msbuild-version AFAIK if you logon in windows, process env.exe runs as well, it can crushing IDE Visual Studio Settings and uninstall some depriciated features from IDE, just like updates feature.

Torchok19081986 avatar Sep 17 '24 11:09 Torchok19081986

System.Text.Json tells me you are trying to target . NET Core family (e.g. .NET8). If this is the case then you cannot use the WiX3 template but a .NET Core version:

image

Note, that WiX does not support .NET Core so I had to opt for the AOT compilation, which brings quite a few limitations. My advice is to stick with .NET Framework (this is the only .NET runtime supported by WiX) and simply bring NewtownSoft.Json to do your JSON stuff

oleg-shilo avatar Sep 18 '24 12:09 oleg-shilo

Every project in the solution I'm currently working on is .NET Framework v4.8. Even when I try to create a project with the .NET Core template I still have the same error with the MSBuild version. I'm using Visual Studio 2019 Professional. How can I say to the template to target .NET Framework, because currently it's not asking me?

veselinoWiktor avatar Sep 18 '24 12:09 veselinoWiktor

Then possibly your VS is not compatible with this project type. I just attached for you the .NET Core project I created on VS2022. If you cannot open it in your, then VS then your VS is just too old.

Setup1.zip

BTW, my advice still stands. I am not sure what advantage you are trying to achieve by bending your older IDE to work with the project type with a strong limitation.

oleg-shilo avatar Sep 18 '24 12:09 oleg-shilo

I couldn't open it.

So when I first tested to create a project with the template, it worked and if I'm not mistaken only by building the project the .msi file was created. So, after that this error that I couldn't load the project started coming up. I created a normal console application added the necessary NuGet packages and now everything works perfectly.

I just want to be able to have .msi file only by building the project , without the console popping out (If that is possible)

PS. On the WixSharp Project Template extension webpage it still says that it works with VS 2019.

veselinoWiktor avatar Sep 18 '24 12:09 veselinoWiktor

There is a confusion here. You are trying to use .NETCore template that is specifically developed for VS2022. And you just confirmed that it does not work on VS2019.

The .NETFramework templates work for VS2019. It has been tested. Unless over the time the VS updates made it incompatible.

without the console popping out (If that is possible)

Yes it is. You just need to invoke your freshly built exe from the project post-build event. After all, it is exactly what the template does.

oleg-shilo avatar Sep 19 '24 12:09 oleg-shilo

@veselinoWiktor try to update Visual Studio Build Tools

Vorval0 avatar Nov 15 '24 11:11 Vorval0