sameerpjoshi
sameerpjoshi
CC#
Created by sameerpjoshi on 6/16/2024 in #help
CMake to generate C# project and compile it
The csproj generated has following entry. Not sure how and where this entry is getting added from <Compile Include="C:\Users\xxxx\source\repos\abcde\xyzc\src\MRC\MRCDNC\out\build\x64-Debug\obj\x64\Debug.NETFramework,Version=v4.0.AssemblyAttributes.cs"> <Link>out\build\x64-Debug\obj\x64\Debug.NETFramework,Version=v4.0.AssemblyAttributes.cs</Link> </Compile>
21 replies
CC#
Created by sameerpjoshi on 6/16/2024 in #help
CMake to generate C# project and compile it
yes I see the generated csproj successfully but the build is failing because of the above errors I mentioned
21 replies
CC#
Created by sameerpjoshi on 6/16/2024 in #help
CMake to generate C# project and compile it
How do I set the nuget package references otherwise when I want to build the C# project using CMake?
21 replies
CC#
Created by sameerpjoshi on 6/16/2024 in #help
CMake to generate C# project and compile it
I have attached the CMakeLists.txt and CMakeSettings.json file
21 replies
CC#
Created by sameerpjoshi on 6/16/2024 in #help
CMake to generate C# project and compile it
21 replies
CC#
Created by sameerpjoshi on 6/16/2024 in #help
CMake to generate C# project and compile it
cmake_minimum_required(VERSION 3.10)
project(MyProject CSharp)
# Add your C# source files
file(GLOB_RECURSE CS_FILES "*.cs")
add_library(MyProject SHARED ${CS_FILES})
set_target_properties(MyProject PROPERTIES
DOTNET_TARGET_FRAMEWORK "netstandard2.0"
)

set_property(TARGET MyProject
PROPERTY VS_PACKAGE_REFERENCES "inContact.DataRepositories_23.2.*;Microsoft.Windows.Compatibility_2.0.1;inContact.NaturalCallingInterfaces_23.2.*;Newtonsoft.Json_13.0.1;System.Configuration.ConfigurationManager_4.7.0;System.Threading.Channels_7.0.0"
)
cmake_minimum_required(VERSION 3.10)
project(MyProject CSharp)
# Add your C# source files
file(GLOB_RECURSE CS_FILES "*.cs")
add_library(MyProject SHARED ${CS_FILES})
set_target_properties(MyProject PROPERTIES
DOTNET_TARGET_FRAMEWORK "netstandard2.0"
)

set_property(TARGET MyProject
PROPERTY VS_PACKAGE_REFERENCES "inContact.DataRepositories_23.2.*;Microsoft.Windows.Compatibility_2.0.1;inContact.NaturalCallingInterfaces_23.2.*;Newtonsoft.Json_13.0.1;System.Configuration.ConfigurationManager_4.7.0;System.Threading.Channels_7.0.0"
)
This is the CMakeLists.txt file
21 replies
CC#
Created by sameerpjoshi on 6/16/2024 in #help
CMake to generate C# project and compile it
If I use msbuild directly , it works fine. I have used WSL for C++ compilation as well for Linux using MSBuild. However, not been able to make it work with CMake. CMake could give me a single way to have the files listed and projects created automatically during runtime and able to build it cross platform. CMake also triggers msbuild while building and when its at the first step of determining projects to restore, we get this error. It seems the msbuild that gets triggered through CMake is using the Csproj file for finding the dependencies. Not sure why its looking for .NET4.0 version of those dependencies when the target framework specified is .Netstandard2.0.
21 replies
CC#
Created by sameerpjoshi on 6/16/2024 in #help
CMake to generate C# project and compile it
I have a mix of C++ and C# projects in my solution which I wanted to build cross platform Linux and Windows. This is the reason to use CMake.
21 replies
CC#
Created by sameerpjoshi on 6/16/2024 in #help
CMake to generate C# project and compile it
The issue is occurring for many other packages as well which support .netstandard2.0 . It seems some issue with csproj file generated that its going to find some other non required version like net40 for the package targets. Not sure where its getting this net40 from
21 replies
CC#
Created by sameerpjoshi on 6/16/2024 in #help
CMake to generate C# project and compile it
The package is internal to our company, so it cant be shared. Its a nuget package internally used in company.
21 replies
CC#
Created by sameerpjoshi on 6/16/2024 in #help
CMake to generate C# project and compile it
This package for now renamed to "abc.xyz" has both support of .netframework 4.8 and .netstandard2.0
21 replies