mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-05 13:20:47 -06:00
VS: Fix DOTNET_SDK builds when no VS_PACKAGE_REFERENCES set
nuget restore always needs to be run for the new DOTNET_SDK style projects, even when VS_PACKAGE_REFERENCES is empty. Fixes: #23405
This commit is contained in:
@@ -5924,7 +5924,8 @@ void cmVisualStudio10TargetGenerator::UpdateCache()
|
||||
{
|
||||
std::vector<std::string> packageReferences;
|
||||
|
||||
if (this->GeneratorTarget->HasPackageReferences()) {
|
||||
if (this->GeneratorTarget->IsDotNetSdkTarget() ||
|
||||
this->GeneratorTarget->HasPackageReferences()) {
|
||||
// Store a cache entry that later determines, if a package restore is
|
||||
// required.
|
||||
this->GeneratorTarget->Makefile->AddCacheDefinition(
|
||||
@@ -5941,7 +5942,7 @@ void cmVisualStudio10TargetGenerator::UpdateCache()
|
||||
OrderedTargetDependSet depends(unordered, CMAKE_CHECK_BUILD_SYSTEM_TARGET);
|
||||
|
||||
for (cmGeneratorTarget const* dt : depends) {
|
||||
if (dt->HasPackageReferences()) {
|
||||
if (dt->IsDotNetSdkTarget() || dt->HasPackageReferences()) {
|
||||
this->GeneratorTarget->Makefile->AddCacheDefinition(
|
||||
cmStrCat(this->GeneratorTarget->GetName(),
|
||||
"_REQUIRES_VS_PACKAGE_RESTORE"),
|
||||
|
||||
@@ -24,9 +24,8 @@ function(runCmakeAndBuild CASE)
|
||||
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
|
||||
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
|
||||
run_cmake(${CASE})
|
||||
set(build_flags /restore)
|
||||
run_cmake_command(${CASE}-build ${CMAKE_COMMAND} --build . -- ${build_flags})
|
||||
run_cmake_command(${CASE}-build ${CMAKE_COMMAND} --build .)
|
||||
endfunction()
|
||||
|
||||
runCmakeAndBuild(VsDotnetSdkCustomCommandsTarget)
|
||||
runCmakeAndBuild(VsDotnetSdkNugetRestore)
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
Determining projects to restore
|
||||
8
Tests/RunCMake/VsDotnetSdk/VsDotnetSdkNugetRestore.cmake
Normal file
8
Tests/RunCMake/VsDotnetSdk/VsDotnetSdkNugetRestore.cmake
Normal file
@@ -0,0 +1,8 @@
|
||||
enable_language(CSharp)
|
||||
if(NOT CMAKE_CSharp_COMPILER)
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(CMAKE_DOTNET_SDK "Microsoft.NET.Sdk")
|
||||
|
||||
add_executable(foo csharponly.cs lib1.cs)
|
||||
Reference in New Issue
Block a user