Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Register
  • Sign in
  • CMake CMake
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 4.2k
    • Issues 4.2k
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 11
    • Merge requests 11
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Artifacts
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • CMakeCMake
  • CMakeCMake
  • Issues
  • #23166
Closed
Open
Issue created Jan 31, 2022 by Remy Jette@remyjette

VS: DOTNET_SDK skips VS_DOTNET_REFERENCE_<refname>

Here's a sample CMakeLists.txt, running 3.22.20220130-ga1f5e268.

cmake_minimum_required(VERSION 3.22.0) # Need CMake 3.22 nightly

project(testproject LANGUAGES CSharp)

include(CSharpUtilities)

add_executable(HelloWorld "HelloWorld.cs")

set_target_properties(HelloWorld PROPERTIES
    DOTNET_TARGET_FRAMEWORK_VERSION "4.7.2"

    VS_DOTNET_REFERENCE_SomeDll
        ${PROJECT_SOURCE_DIR}/SomeDll.dll
)

This works. I see the following block in HelloWorld.csproj:

  <ItemGroup>
    <Reference Include="SomeDll">
      <CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
      <ReferenceOutputAssembly>true</ReferenceOutputAssembly>
      <Private>True</Private>
      <HintPath>D:\src\test\SomeDll.dll</HintPath>
    </Reference>
  </ItemGroup>

Now let's switch the CMakeLists.txt to use DOTNET_SDK instead:

cmake_minimum_required(VERSION 3.22.0) # Need CMake 3.22 nightly

project(testproject LANGUAGES CSharp)

include(CSharpUtilities)

add_executable(HelloWorld "HelloWorld.cs")

set_target_properties(HelloWorld PROPERTIES
    DOTNET_SDK "Microsoft.NET.Sdk"
    DOTNET_TARGET_FRAMEWORK "net472"

    VS_DOTNET_REFERENCE_SomeDll
        ${PROJECT_SOURCE_DIR}/SomeDll.dll
)

Here's the generated .csproj. No reference to SomeDll.dll at all:


<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup Label="Globals">
    <ProjectGuid>{830F543F-6CA4-334B-A6AF-DD7F74128D60}</ProjectGuid>
    <Keyword>Win32Proj</Keyword>
    <EnableDefaultItems>false</EnableDefaultItems>
    <VCProjectUpgraderObjectName>NoUpgrade</VCProjectUpgraderObjectName>
    <ManagedAssembly>true</ManagedAssembly>
    <TargetFramework>net472</TargetFramework>
    <OutputType>Exe</OutputType>
  </PropertyGroup>
  <ItemGroup>
    <Compile Include="D:\src\test\HelloWorld.cs">
      <Link>HelloWorld.cs</Link>
    </Compile>
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="D:\src\test\_build\ZERO_CHECK.vcxproj">
      <Project>{5CC0DD8F-7421-34B1-895D-419276575F16}</Project>
      <Name>ZERO_CHECK</Name>
      <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
      <CopyToOutputDirectory>Never</CopyToOutputDirectory>
    </ProjectReference>
  </ItemGroup>
</Project>

I tried target_link_libraries with the path to the DLL but that didn't work either.

VS_PACKAGE_REFERENCES works perfectly, but I can't find a way to reference a pre-compiled .dll I have on disk with DOTNET_SDK.

Edited Feb 01, 2022 by Brad King
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking