premake / premake-core

Premake
https://premake.github.io/
BSD 3-Clause "New" or "Revised" License
3.24k stars 618 forks source link

How can I set a directory for Visual studio on where the newly created files should actually be created? #2147

Closed GasimGasimzada closed 1 year ago

GasimGasimzada commented 1 year ago

What's your question?

I have a premake for my project like this:

# project structure
/.premake/workspace.lua
/engine/premake5.lua
/engine/src/...
/premake5.lua
-- .premake/workspace.lua
workspace "Engine"
  basedir "../workspace"

-- engine/premake5.lua
project "Engine"
    basedir "../workspace/engine"
    kind "StaticLib"
    files {
      "src/**.cpp", "src/**.h"
    }

-- premake5.lua (root)
include '.premake/workspace'
include 'engine/'

When I run premake5 vs2022 + build my project, the following new directories are created:

/workspace/Engine.sln
/workspace/engine/Engine.vcxproj
/workspace/obj/*
/workspace/bin/*
# bunch of other settings

This works well and as intended since I want all my autogenerated files to be in one directory that I can easily gitignore.

However, this config has one issue, particularly in VS2022 (frankly, I have not checked it in other editors). When I try to use Visual studio to create new source files in my project, the files are created under workspace/engine by default. However, I want the files to be created in engine/src/. Is there a way to change this directory to always point to the engine/src; so, I do not need to leave visual studio or manually modify the path of newly created file?

nickclark2016 commented 1 year ago

To my awareness, this is limitation with Visual Studio and it's internal behavior. By default, Visual Studio will try to make the file in the same directory as the project file. If you're able to find a project configuration that corresponds to the default create location, let me know.