C
C#•2mo ago
Cyclomatic

Directory.Build.props

Hi, I want to use the Directory.Build.props file to set the <OutDir> of all projects in the solution. I want to set the path relative to the Directory.Build.props file itself, is this possible?
8 Replies
Anton
Anton•2mo ago
Both yes and no. You're going to struggle making nuget work properly. Don't bother. I have been through this it's not pleasant
Cyclomatic
Cyclomatic•2mo ago
it is already not pleasant 😄 all my projects are already being built to the same directory but each project specifies the output path. there's also a nuget.config at the root of the repo that specifies where the nuget packages need to be output I wanto share a project from one repo in another repo, and hence trying to introduce the Dependency.Build.props file to get around some issues I am having in setting the output directory in the project itself
Anton
Anton•2mo ago
if it's a question of not being used to tye typical bin/obj directories, give it up if it's an actual business need, it's a different question
Cyclomatic
Cyclomatic•2mo ago
i dont understand what you are saying. the files are already being built and output to a common directory from all projects in my repo. i just want to achieve the same thing using a Directory.Build.props file. Given the folder structure, I need the Directory.Build.props to specify the output folder for all projects and the only I see to achieve this is by knowing the path of the Directory.Build.props file from the file itself. let's not worry about nuget for the time being, one step at a time 🙂
Anton
Anton•2mo ago
exactly, doing it through build props is problematic, because of the import order build props gets imported in the middle of importing the sdk and it becomes really messy MSBuildThisFileDirectory is the property that you want but even if you do it like that it will have subtle bugs
Cyclomatic
Cyclomatic•2mo ago
so if not through a build props file, how can I achieve what I want - keep the csproj agnostic about where it builds the output file yeah I tried that, but I think that was giving me the path of the .csproj rather than the props file
Anton
Anton•2mo ago
You must have tried MSBuildProjectDirectory
Cyclomatic
Cyclomatic•2mo ago
hmm weird, you're right, that's the one. i did try it but it hadn't worked as expected. but now it seems to thanks
Want results from more Discord servers?
Add your server