question

KelYOY-8616 avatar image
0 Votes"
KelYOY-8616 asked KelYOY-8616 commented

Importing information to a .sln file

I have a root directory in a .props file that I want to use as a reference for the directories found in one of my .sln files, in the same way I can make a $(root_example) variable, and put that into a directory reference. I know .sln files have their own language separate from something like C# or Python however, so I can't tell if this is something I could do with a .sln file.

vs-msbuild
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

TianyuSun-MSFT avatar image
0 Votes"
TianyuSun-MSFT answered KelYOY-8616 commented

Hello @KelYOY-8616 ,

Welcome to Microsoft Q&A forum.

I suppose what you mentioned should be MSBuild, and the .sln file you mentioned should be .xxproj file.

Perhaps you need to read this document: Directory.Build.props and Directory.Build.targets and this document: MSBuild properties.

Based on my test, I provide you with a simple example:

1). Create a Directory.Build.props file and put it under the correct directory(I put it in solution folder).

2). Open and add XML to this file, for example

 <Project>
  <PropertyGroup>
    <MyPath>bin\test</MyPath>
  </PropertyGroup>
 </Project>

3). Save and close it.

4). In VS, right-click the project > Unload Project > right-click the project again > Edit Project file, and you will see the .xxproj file.

5). Sine I just provide a MyPath property in the Directory.Build.props file, I edited the <OutputPath> </ OutputPath > property and tried to use MyPath property in it. I changed it from <OutputPath>bin\Debug\</ OutputPath > to <OutputPath>$(MyPath)</ OutputPath >, and then saved this file > Reload Project > Build my project and the newly output files were generated to the MyPath.

Best Regards,
Tianyu


If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks for the feedback. This wasn't quite what I had in mind, but it seems like a good enough alternative to the initial problem. I couldn't quite find a simple equivalent to my initial question, so I'll try to work with this.

0 Votes 0 ·