When I use Cpp dll to C#, finding CppSharp project, so I tried.
I have 2 difference .net framework (7.0.408 and 8.0.202) in my machine. When I set -target-framework net7.0, it can't select 7.0.408, but 8.0.202. The detailed process is as follows.
OS: Windows 11
Used headers
I use VS developer command prompt and sh for Git, run the code, and got error:
sh build.sh generate -configuration Release -platform x64 -target-framework net7.0
/* Everything is Ok */
sh build.sh -configuration Release -platform x64 -target-framework net7.0
/* error */
C: \ Program Files\dotnet\sdk\8.0.202\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targe
ts(154,5): error NETSDK1145: The Apphost package is not installed, and the NuGet package is not supported. Upgrade Visual Studio, remove global.json (if it specifies a specific SDK version), and uninstall the newer SDK. If needed
For more options, visit https://aka.ms/targeting-apphost-pack-missing package type :Apphost, package directory: C:\Program Files\dotnet\packs\Microsoft.NETCo
Re. App. Host. Win - x64 targetframework: net7.0, package Id: Microsoft.NET. The Core App. Host. Win - x64, package version: 7.0.17 [D: \ CppSharp \ CppSharp
1.1 \ build \ vs2022 \ projects \ CppSharp Parser. CLI. Vcxproj]
So, I try generate by CppSharp.sln, run to run the tests sh test.sh, and got error:
Unhandled exception. System.ArgumentOutOfRangeException: length ('-1') must be a non-negative value. (Parameter 'length')
Actual value was -1.
at System.ArgumentOutOfRangeException.ThrowNegative[T](T value, String paramName)
at System.ArgumentOutOfRangeException.ThrowIfNegative[T](T value, String paramName)
at System.String.ThrowSubstringArgumentOutOfRange(Int32 startIndex, Int32 length)
at System.String.Substring(Int32 startIndex, Int32 length)
at vstest.console.Internal.FilePatternParser.SplitFilePatternOnWildCard(String filePattern) in /_/src/vstest.console/Internal/FilePatternParser.cs:line 101
at vstest.console.Internal.FilePatternParser.GetMatchingFiles(String filePattern) in /_/src/vstest.console/Internal/FilePatternParser.cs:line 75
at Microsoft.VisualStudio.TestPlatform.CommandLine.CommandLineOptions.AddSource(String source) in /_/src/vstest.console/CommandLine/CommandLineOptions.cs:line 283
at Microsoft.VisualStudio.TestPlatform.CommandLine.Processors.ArgumentProcessorFactory.<>c__DisplayClass18_0.<WrapLazyProcessorToInitializeOnInstantiation>b__0() in /_/src/vstest.console/Processors/Utilities/ArgumentProcessorFactory.cs:line 282
at System.Lazy`1.CreateValue()
at Microsoft.VisualStudio.TestPlatform.CommandLine.Processors.ArgumentProcessorFactory.<>c__DisplayClass18_0.<WrapLazyProcessorToInitializeOnInstantiation>b__0() in /_/src/vstest.console/Processors/Utilities/ArgumentProcessorFactory.cs:line 272
at System.Lazy`1.CreateValue()
at Microsoft.VisualStudio.TestPlatform.CommandLine.Executor.GetArgumentProcessors(String[] args, List`1& processors) in /_/src/vstest.console/CommandLine/Executor.cs:line 283
at Microsoft.VisualStudio.TestPlatform.CommandLine.Executor.Execute(String[] args) in /_/src/vstest.console/CommandLine/Executor.cs:line 173
at Microsoft.VisualStudio.TestPlatform.CommandLine.Program.Main(String[] args) in /_/src/vstest.console/Program.cs:line 22
I am not sure about the issue, but I think target-framework only changes the output of TargetFramework in the generated csproj, it does not choose which .NET SDK install is used.
Brief Description
When I use Cpp dll to C#, finding CppSharp project, so I tried. I have 2 difference .net framework (7.0.408 and 8.0.202) in my machine. When I set
-target-framework net7.0
, it can't select 7.0.408, but 8.0.202. The detailed process is as follows.OS: Windows 11
Used headers
I use VS developer command prompt and sh for Git, run the code, and got error:
So, I try generate by
CppSharp.sln
, run to run the testssh test.sh
, and got error: