Skip to content
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

Building a nuget package from the source code #259

Open
nuller1joe opened this issue Nov 16, 2022 · 5 comments
Open

Building a nuget package from the source code #259

nuller1joe opened this issue Nov 16, 2022 · 5 comments

Comments

@nuller1joe
Copy link

Hey

I'm having some trouble getting the nuget package working building it myself.

After building the latest source code with msbuild /p:PublicRelease=true

I get a nuget package in ./ErrorProne.NET.StructAnalyzers.CodeFixes/bin/debug/ErrorProne.NET.Structs.0.5.0-beta6.nupkg
(likewise for Core Analyzers)

Adding the package to my local nuget repo: nuget add './ErrorProne.NET.StructAnalyzers.CodeFixes/bin/debug/ErrorProne.NET.Structs.0.5.0-beta6.nupkg' -Source 'c:/store' and adding the local store to my project NuGet.config allows me to see and install the package.

After installing the locally created nuget package, no warnings or errors is appearing.

If I use the official nuget repo to install 0.4.0-beta.1 I get all the expected warnings. However, if I build the commit for the release of 0.4.0, it doesn't work either. Same with 0.3.0.

Do I need to set any flags to get the local built analyzer working?

@munik
Copy link

munik commented Jan 4, 2024

I'm also running into the same issue and unable to get a working NuGet package output from the build.

@nuller1joe
Copy link
Author

nuller1joe commented Jan 5, 2024

The solution I came up with that worked for me:

Following is based on the git commit: f6787c08d76ca761eee3d103f43c4289bbb4d3cb

The newest official nuget package (v.0.4.0-beta.1) did not work correctly.
Neither did newest commit (f6787c08d76ca761eee3d103f43c4289bbb4d3cb) which should be version 0.5.0

I have done some slight changes to get it working.

1) In order to run this project at all, visual studio needs to be installed (it is a bit sensitive to which version of VS I think). I used Visual Studio Enterprise 2022 v17.4.1
2) There exist two patches that is my changes upon official commit f6787c08d76ca761eee3d103f43c4289bbb4d3cb
    - ./patchBasic.diff which only changes the minimum to actually be able to open and build the project
    - ./patchExtende2d.diff which contains the code changes to not throw when analyzing. Furthermore FxCopAnalyzer was replaced with DotnetAnalyzwer. A range of nuget packages was updated
3) To build (Navigate to ./src):
    - Run: dotnet restore
    - Run: msbuild /p:PublicRelease=true
4) Install newly built nuget package:
    - .\nuget.exe add .\ErrorProne.NET.StructAnalyzers.CodeFixes\bin\Debug\ErrorProne.NET.Structs.0.5.0-beta.6.nupkg -Source ..\..
    (where source is the project you want the nuget package added to)
    - After running the command go to source path and find 'errorprone.net.structs\0.5.0-beta.6'
    - Open 'errorprone.net.structs.0.5.0-beta.6.nupkg' as a ZIP file, and extract (and replace) all files in 'errorprone.net.structs\0.5.0-beta.6'
5) Same can be done for the CoreAnalyzer if needed

patchExtended2.diff.txt
patchBasic.diff.txt

I hope this helps you

@munik
Copy link

munik commented Jan 5, 2024

@nuller1joe thanks for that, but I need to be able to run a build that produces working .nupkg files. As it is, I get an error about RuntimeContracts.dll missing when I run the analyzer in the .nupkg files that are currently generated. It looks like the very last commit (3aebd27) commented out the <ILRepack ... /> directive which I'm guessing is not bundling RuntimeContracts.dll like it should be. But I'm not sure.

@SergeyTeplyakov can you provide any input here?

@munik
Copy link

munik commented Jan 5, 2024

@mkerkelpgr I'm not sure, but possibly your change in 3aebd27 resulted in the NuGet packages not being created. I don't understand the build infra for this project -- do you know what it was supposed to do and/or are you able to create working NuGet packages?

@mkerkelpgr
Copy link
Contributor

@SergeyTeplyakov @munik I am awaiting to hear from Sergey on that issue as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants