-
Notifications
You must be signed in to change notification settings - Fork 182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using PackageReference instead of packages.config doesn't appear to work #620
Comments
@oleg-shilo I solved this by:
Could you let me know if this is the recommended approach? Thank you! |
Well, not exactly :o) For quite some time If you have problems with SetEnvVar.dll then most likely you are using older VS templates. Updating WixSharp project templetes extension will solve this problem. However... I just found that NuGet restore does not recreate the project structure the way it supposed to. I am changing theist issue to BUG and will investigate it. |
After some further digging I found that NuGet package is still invoking The packages have been fixed (v1.9.5.1) and published. This will solve the problem of installing package on a brand new plain .NET project. The templates fix is yet to come. |
@oleg-shilo as always thank you very much for your amazing library and help using it! |
The VS project templates extension has also been fixed updated (v1.8.0): |
Hi @oleg-shilo, I tried out the new templates (v1.8.0) and they are still using packages.config and placing dlls into the local project "packages" directory. However; if you use the new PackageReference mechanism the nuget packages get stored in the /.nuget folder. It does seem to work for me if I use the PackageReference approach and only include (added by nuget automatically) in my csproj file.
If I look in my obj directory there is a targets file that is automatically generated by Visual Studio. It contains:
So it appears that all the necessary targets are being pulled in and that I do not need to do anything in the csproj file. Is that correct? To summarize, every things seems work without having to use the WixSharpProjectTemplates if you use the PackageReference approach. Are the templates for backward compatibility, or am I missing something? What is the minimum requirement in the csproj file for Wixsharp to function properly using the PackageReference approach? |
@oleg-shilo I think I must have closed this accidentally. Please see my comment above. |
I think there is a bit of confusion about this issue. I need to explain.... The problem with Having nuget references as a The real problem is that having project-listed packages does not play well with project templates. Despite my all effort was not able to find a solution when the template would allow project-listed packages. Furthermore, having project-listed packages prevents templates from being integrated with VS2015. However if one starts with the plain C# console app then he can add nuget packages either way, globally or per project (packages.config) |
Ok, thanks for the explanation. Everything is working fine for me so I will close the bug. |
Hello @oleg-shilo, Thanks! |
But if you want to pass any sort of information into the project you can still red envars that you may set in the pre-build project events. But if you want a complete flexibility then you can install |
Hmm. I'm also trying to use SetEnvVars. @oleg-shilo Could you possibly furnish the commit where it was deleted? My use case is different - I have multiple project configurations and I would like to access those. I can't seem to find this feature in wixsharp, this seems the closest. However, it doesn't seem to work... (could be an msbuild/dotnet mismatch). All we have is the dll and the source file, with no way to build. Hard to debug... EDIT: I see commit 13bde13 removed it from the .targets file, so the wiki is currently incorrect: i.e. So I would have to use a very old version of wixsharp to get this working at all, and I am on WixSharp_wix4 (2.1.5)... alright. I tried using Sorry to necro, hopefully useful comments for someone in future! |
If you are creating a new project use VS templates. |
Yes I ended up impling my own msbuild task, there was no way to pull build config settings from the csproj. SetEnvVariable wasn't any good either as env vars are transient. I used the VS templates but those provided no way to pull build information. |
Can you elaborate on that? Not sure what you are trying to achieve. |
There is various information available to the build system, most notably So I have a different build and different packaging needs for e.g. Debug vs Release (perhaps not a common need, but one I want nonetheless).
This "relative dir" approach however is insufficient for doing anything more complex with the build. |
Currently the old <Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="cd .\
set ide=true
"$(TargetPath)"" />
</Target> You can extend this approach to do more, like passing the context for the build script: And then: static void Main(string[] args)
{
var myArg = args.FirstOrDefault(x=>x.StartsWith("-myArg"))?.Split(':').Last(); |
Ah, that's what that thing does. I have it commented out, it was causing build failures, and the unicode escapes don't make for easy reading. I think I'll stick with my current task - I have it wrapping a json file so I get (some) type safety, and marshalling for free. Bonus, I know exactly what it ran with vs having to debug or dump it. |
These two link can help to understand the build process: https://github.com/oleg-shilo/wixsharp/wiki/VS2019-%E2%80%93-2022-Templates |
Hmm. I was going to say the reason it breaks is the first time you build the target doesn't exist, but I think its more complex than that... I'll try it again and see what's wrong with your template. I do think clearer documentation could be helpful, too (such as removing the old invalid hint and updating with current supported process). |
I am happy to process any feedback. But I may need your help in understanding the gaps.
|
search for this paragraph:
Your VS integration page is actually not very helpful, I found the templates without finding your page and created a project. Then your page just looks like you're walking someone through how to use VS templates, which I suppose if you've never created a project before might be helpful, but its not what I'm looking for when I already have a working project that builds in Visual Studio (except for one weird bit of code that is a bit inscrutable). I think the problem is you tried to make it too seamless and so when something breaks, its hidden inside weird-looking code buried at the bottom of a page that looks like it is not relevant. You show some images of setting command line parameters, but there's never any textual mention of what to do, so I never found it (especially by search).
Which I think is the other part of this - that task should perhaps be disabled by default in the build scripts, rather than on and always running (IIRC I just wanted it to build and it failed). Then you can explicitly mention how to run the installer as part of the build by uncommenting the task. |
Thank you @smaudet. I have updated the documentation according to your feedback.
Unfortunately, it's not that simple. Disabling the post-build event simply prevents msi from building. Thus the build script will be compiled but never executed. And the user feedback I received previously indicated the strong expectations of msi file being produced as the result of building the VS project. Particularly, if the project is part of the CI. |
Hello @oleg-shilo
I know you have covered this before, but I cannot get PackageReference to work properly with Wixsharp. I always get the error below. I have tried creating new setup projects from the Wixsharp templates, however; they all seem to use Package.config.
Any hints on how to solve this issue?
Severity Code Description Project File Line Suppression State
Error The "SetEnvVar" task was not found. Check the following: 1.) The name of the task in the project file is the same as the name of the task class. 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface. 3.) The task is correctly declared with in the project file, or in the *.tasks files located in the "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin" directory. WixSharp Setup1 C:\Users\jonre.nuget\packages\wixsharp\1.9.5\build\WixSharp.targets 5
Steps to reproduce:
The text was updated successfully, but these errors were encountered: