Repository navigation
Fix duplicate native DLLs in net4x output directory #1886
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
bf539c1
Fix duplicate native DLLs in net4x output directory (#1765)
shimat d5ef5cd
Add developer documentation and CLAUDE.md
shimat 50b2280
Consolidate AI instructions into copilot-instructions.md
shimat dbed22b
Add CLAUDE.md pointing to copilot-instructions.md
shimat b6b15c0
Mark #1765 as resolved in issue backlog
shimat 7301dfe
Fix UTF-8 BOM on CLAUDE.md
shimat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| See `.github/copilot-instructions.md` for development instructions. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| # Release Process | ||
|
|
||
| This document describes the steps required to publish a new version of OpenCvSharp. | ||
|
|
||
| --- | ||
|
|
||
| ## Version numbering | ||
|
|
||
| NuGet package versions follow the pattern `{opencv_version}.{YYYYMMDD}`, e.g. `4.13.0.20260530`. The `-beta` suffix is stripped by `OpenCvSharp.NupkgBetaRemover` at publish time. | ||
|
|
||
| The version is passed at pack time via `-p:Version=...` in CI. **No source file needs to be edited to change the version number.** | ||
|
|
||
| ### Assembly versioning policy | ||
|
|
||
| Managed assembly attributes are set as follows (see `src/Directory.Build.props`): | ||
|
|
||
| | Attribute | Value | Rationale | | ||
| |---|---|---| | ||
| | `AssemblyVersion` | `4.0.0.0` (major-pinned, hardcoded) | Changing this on every release is a breaking change for .NET Framework consumers of the strong-named assembly — they would need binding redirects in `app.config`. Only bump the major component when there is a breaking API change. | | ||
| | `FileVersion` | `4.0.0.0` (hardcoded) | The date-based 4th component (e.g. `20260530`) exceeds the 65535 per-component limit of the Windows FILEVERSION PE resource. | | ||
| | `InformationalVersion` | Set automatically by the .NET SDK to `$(Version)` | This is the human-readable version visible in Windows file properties ("Product version") and most tooling. It tracks the NuGet version correctly with no manual action needed. | | ||
|
|
||
| ### When to bump `AssemblyVersion` | ||
|
|
||
| - **Patch / minor OpenCV update** (e.g. 4.13.0 → 4.13.1, or 4.13 → 4.14): **do nothing**. The assembly version stays at `4.0.0.0`. | ||
| - **OpenCV major version bump** (e.g. 4.x → 5.x): update `AssemblyVersion` and `FileVersion` in `src/Directory.Build.props` to `5.0.0.0`. Be aware this is a breaking change for .NET Framework consumers. | ||
| - **Breaking API change in the C# wrapper** (rare): same as above — bump the major component. | ||
|
|
||
| --- | ||
|
|
||
| ## CI workflow | ||
|
|
||
| Releases are produced by running the following workflows in order: | ||
|
|
||
| 1. **`windows.yml`** — builds `OpenCvSharpExtern.dll` (full and slim), runs tests, packs NuGet packages with a `-beta` version suffix. | ||
| 2. **`linux-arm64.yml`** — builds the Linux ARM64 native library. | ||
| 3. **`manylinux.yml`** — builds the Linux x64 native library. | ||
| 4. **`wasm.yml`** — builds the WASM native library. | ||
| 5. **`publish_nuget.yml`** — collects all artifacts, strips the `-beta` suffix via `OpenCvSharp.NupkgBetaRemover`, validates the package set, and pushes to NuGet.org. | ||
|
|
||
| The `OPENCV_VERSION` environment variable in `windows.yml` controls the OpenCV version embedded in the package version string. Update it there when upgrading OpenCV. | ||
|
|
||
| --- | ||
|
|
||
| ## Upgrading OpenCV | ||
|
|
||
| 1. Update the `opencv` and `opencv_contrib` submodules to the new tag. | ||
| 2. Update `OPENCV_VERSION` in `.github/workflows/windows.yml`. | ||
| 3. Update the ffmpeg DLL filename references in `nuget/OpenCvSharp4.runtime.win.props` and `nuget/OpenCvSharp4.runtime.win.csproj` if the ffmpeg DLL name changed (e.g. `opencv_videoio_ffmpeg4130_64.dll` → `opencv_videoio_ffmpeg4140_64.dll`). | ||
| 4. Run the full CI pipeline and verify all tests pass. | ||
| 5. `AssemblyVersion` does **not** need to be changed for a minor/patch OpenCV upgrade. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
| <!-- | ||
| For .NET Framework (net4x) targets using PackageReference, NuGet's build pipeline automatically | ||
| copies runtimes/win-x64/native/ assets to the output root directory. However, the companion | ||
| .props file already places these DLLs under dll/x64/, which is where WindowsLibraryLoader looks | ||
| at runtime. The root copies are therefore redundant and bloat the output directory. | ||
|
|
||
| This target removes the package's native assets from RuntimeCopyLocalItems — the item group | ||
| populated by ResolvePackageAssets — so NuGet does not copy them to the output root. | ||
| The dll/x64/ placement from the .props file is unaffected. | ||
|
|
||
| Note: RuntimeCopyLocalItems is only present in SDK-style projects using PackageReference. | ||
| Old-style (packages.config) projects do not process runtimes/ assets at all, so this target | ||
| has no effect there (which is fine — no duplicate exists in that case either). | ||
| --> | ||
| <Target Name="OpenCvSharp4RuntimeWinSlim_RemoveRootNativeAssets" | ||
| AfterTargets="ResolvePackageAssets" | ||
| Condition="$(TargetFramework.StartsWith('net4')) Or $(TargetFrameworkVersion.StartsWith('v4'))"> | ||
| <ItemGroup> | ||
| <RuntimeCopyLocalItems Remove="@(RuntimeCopyLocalItems)" | ||
| Condition="'%(NuGetPackageId)' == 'OpenCvSharp4.runtime.win.slim'" /> | ||
| </ItemGroup> | ||
| </Target> | ||
| </Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
| <!-- | ||
| For .NET Framework (net4x) targets using PackageReference, NuGet's build pipeline automatically | ||
| copies runtimes/win-x64/native/ assets to the output root directory. However, the companion | ||
| .props file already places these DLLs under dll/x64/, which is where WindowsLibraryLoader looks | ||
| at runtime. The root copies are therefore redundant and bloat the output directory. | ||
|
|
||
| This target removes the package's native assets from RuntimeCopyLocalItems — the item group | ||
| populated by ResolvePackageAssets — so NuGet does not copy them to the output root. | ||
| The dll/x64/ placement from the .props file is unaffected. | ||
|
|
||
| Note: RuntimeCopyLocalItems is only present in SDK-style projects using PackageReference. | ||
| Old-style (packages.config) projects do not process runtimes/ assets at all, so this target | ||
| has no effect there (which is fine — no duplicate exists in that case either). | ||
| --> | ||
| <Target Name="OpenCvSharp4RuntimeWin_RemoveRootNativeAssets" | ||
| AfterTargets="ResolvePackageAssets" | ||
| Condition="$(TargetFramework.StartsWith('net4')) Or $(TargetFrameworkVersion.StartsWith('v4'))"> | ||
| <ItemGroup> | ||
| <RuntimeCopyLocalItems Remove="@(RuntimeCopyLocalItems)" | ||
| Condition="'%(NuGetPackageId)' == 'OpenCvSharp4.runtime.win'" /> | ||
| </ItemGroup> | ||
| </Target> | ||
| </Project> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.