Как изменить file path visual studio

This repo is the home of the official Visual Studio, Visual Studio for Mac, Visual Studio Subscriptions, and Scripting Technologies documentation for Microsoft. - visualstudio-docs/how-to-change-th...
title description ms.custom ms.date ms.technology ms.topic helpviewer_keywords ms.assetid author ms.author manager ms.workload

Change the build output directory

Learn how you can specify the location of output generated by your project on a per-configuration basis (for debug, release, or both).

contperf-fy22q3

06/15/2022

vs-ide-compile

how-to

output directory, changing

a8333c89-afb2-4b1d-b2e2-9146da852402

ghogen

ghogen

jmartens

multiple

How to: Change the build output directory

[!INCLUDE Visual Studio]

You can specify the location of output generated by your project on a per-configuration basis (for debug, release, or both).

:::moniker range=»vs-2019″

Change the build output directory

  1. To open the project’s property pages, right-click on the project node in Solution Explorer and select Properties.

  2. Select the appropriate tab based on your project type:

    • For C#, select the Build tab.
    • For Visual Basic, select the Compile tab.
    • For C++ or JavaScript, select the General tab.
  3. In the configuration drop-down at the top, choose the configuration whose output file location you want to change (Debug, Release, or All Configurations).

  4. Find the output path entry on the page—it differs depending on your project type:

    • Output path for C# and JavaScript projects
    • Build output path for Visual Basic projects
    • Output directory for Visual C++ projects

    Type in the path to generate output to (absolute or relative to the root project directory), or choose Browse to browse to that folder instead.

    Output path property for a Visual Studio C# project

    [!NOTE]
    Some projects will by default include framework and runtime in the build path. To change this, right-click the project node in Solution Explorer, select Edit Project File, and add the following:

    <PropertyGroup>
      <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
      <AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
    </PropertyGroup>

[!TIP]
If the output is not being generated to the location that you specified, make sure you’re building the corresponding configuration (for example, Debug or Release) by selecting it on the menu bar of Visual Studio.

Build configuration picker in Visual Studio 2019.

:::moniker-end

:::moniker range=»>=vs-2022″

Change the build output directory

In Visual Studio 2022, there are different Project Designer user interfaces, depending on your project type. C# .NET Framework and all Visual Basic projects use the legacy .NET Project Designer, but C# .NET Core (and .NET 5 and later) projects use the current .NET Project Designer. C++ projects use their own property pages user interface. The steps in this section depend on what Project Designer you’re using.

To change the build output directory using the legacy .NET Project Designer or C++ property pages

  1. Right-click on the project node in Solution Explorer and select Properties.

  2. Select the appropriate tab based on your project type:

    • For C#, select the Build tab.
    • For Visual Basic, select the Compile tab.
    • For C++ or JavaScript, select the General tab.
  3. In the configuration drop-down at the top, choose the configuration whose output file location you want to change (Debug, Release, or All Configurations).

  4. Find the output path entry on the page—it differs depending on your project type:

    • Output path for C# and JavaScript projects
    • Build output path for Visual Basic projects
    • Output directory for Visual C++ projects

    Type in the path to generate output to (absolute or relative to the root project directory), or choose Browse to browse to that folder instead.

    Output path property for a C# .NET Framework project

    [!NOTE]
    Some projects will by default include framework and runtime in the build path. To change this, right-click the project node in Solution Explorer, select Edit Project File, and add the following:

    <PropertyGroup>
      <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
      <AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
    </PropertyGroup>

To change the build output directory using the current .NET Project Designer

  1. Right-click on the project node in Solution Explorer and select Properties.

  2. Expand the Build section, and select the Output subsection.

  3. Find the Base output path for C#, and type in the path to generate output to (absolute or relative to the root project directory), or choose Browse to browse to that folder instead. Note that the configuration name is appended to the base output path to generate the actual output path.

    Output path property for a .NET Core C# project

    [!NOTE]
    Some projects will by default include framework and runtime in the build path. To change this, right-click the project node in Solution Explorer, select Edit Project File, and add the following:

    <PropertyGroup>
      <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
      <AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
    </PropertyGroup>

[!TIP]
If the output is not being generated to the location that you specified, make sure you’re building the corresponding configuration (for example, Debug or Release) by selecting it on the menu bar of Visual Studio.

Build configuration picker in Visual Studio 2022.
:::moniker-end

Build to a common output directory

By default, [!INCLUDEvsprvs] builds each project in a solution in its own folder inside the solution. You can change the build output paths of your projects to force all outputs to be placed in the same folder.

To place all solution outputs in a common directory

  1. Click on one project in the solution.

  2. On the Project menu, click Properties.

  3. In each project, depending on its type, select either Compile or Build, and set the Output path or Base output path to a folder to use for all projects in the solution.

  4. Open the project file for the project, and add the following property declaration to the first property group.

    <PropertyGroup>
      <!-- existing property declarations are here -->
      <UseCommonOutputDirectory>true</UseCommonOutputDirectory>
    </PropertyGroup>

    Setting UseCommonOutputDirectory to true tells Visual Studio and its underlying build engine (MSBuild) that you’re putting multiple project outputs in the same folder, and so MSBuild omits the copying step that normally happens when projects depend on other projects.

  5. Repeat steps 1-4 for all projects in the solution. You can skip some projects if you have some exceptional projects that should not use the common output directory.

To set the intermediate output directory for a project (.NET projects)

  1. Open the project file.

  2. Add the following property declaration to the first property group.

    <PropertyGroup>
      <!-- existing property declarations are here -->
      <IntermediateOutputPath>path</IntermediateOutputPath>
    <PropertyGroup>

    The path is relative to the project file, or you can use an absolute path. If you want to put the project name in the path, you can reference it by using the MSBuild properties $(MSBuildProjectName), $(MSBuildProjectDirectory). For more properties you can use, see MSBuild reserved and well-known properties.

  3. Visual Studio still creates the obj folder under the project folder when you build, but it’s empty. You can delete it as part of the build process. One way to do that is to add a post-build event to run the following command:

    rd "$(ProjectDir)obj" /s /q

    See Specify custom build events.

    The obj folder is not created when you build from the MSBuild command line.

See also

  • Build page, Project Designer (C#)
  • General Property page (project)
  • Compile and build

How do I set a path for DLL files to be searched in Visual Studio for a particular project alone?

Now I am setting it in the environment path variable, but I would like better control over this.

Peter Mortensen's user avatar

asked Jan 9, 2009 at 13:46

yesraaj's user avatar

4

Search MSDN for «How to: Set Environment Variables for Projects». (It’s Project>Properties>Configuration Properties>Debugging «Environment» and «Merge Environment» properties for those who are in a rush.)

The syntax is NAME=VALUE and macros can be used (for example, $(OutDir)).

For example, to prepend C:WindowsTemp to the PATH:

PATH=C:WINDOWSTemp;%PATH%

Similarly, to append $(TargetDir)DLLS to the PATH:

PATH=%PATH%;$(TargetDir)DLLS

CharlesB's user avatar

CharlesB

84.4k27 gold badges189 silver badges214 bronze badges

answered May 26, 2010 at 19:28

Multicollinearity's user avatar

6

You have a couple of options:

  • You can add the path to the DLLs to the Executable files settings under Tools > Options > Projects and Solutions > VC++ Directories (but only for building, for executing or debugging here)
  • You can add them in your global PATH environment variable
  • You can start Visual Studio using a batch file as I described here and manipulate the path in that one
  • You can copy the DLLs into the executable file’s directory :-)

Community's user avatar

answered Jan 9, 2009 at 14:26

Timo Geusch's user avatar

Timo GeuschTimo Geusch

24k5 gold badges51 silver badges70 bronze badges

5

If you only need to add one path per configuration (debug/release), you could set the debug command working directory:

Project | Properties | Select Configuration | Configuration Properties
| Debugging | Working directory

Repeat for each project configuration.

Jorgesys's user avatar

Jorgesys

123k23 gold badges328 silver badges264 bronze badges

answered May 9, 2009 at 16:49

sean e's user avatar

sean esean e

11.7k3 gold badges43 silver badges56 bronze badges

Set the PATH variable, like you’re doing. If you’re running the program from the IDE, you can modify environment variables by adjusting the Debugging options in the project properties.

If the DLLs are named such that you don’t need different paths for the different configuration types, you can add the path to the system PATH variable or to Visual Studio’s global one in Tools | Options.

answered Jan 9, 2009 at 14:19

Mr Fooz's user avatar

Mr FoozMr Fooz

107k5 gold badges70 silver badges101 bronze badges

None of the answers solved exactly my problem (the solution file I was running was trying to find xcopy to copy a dll after generation).

What solved it for me was going into menu «Project -> Properties»

Then in the window that opens choosing on the left pane: «Configuration Properties -> VC++ Directories

On the right pane under «General» choosing «Executable Directories «

And then adding:

$(SystemRoot)system32;$(SystemRoot);$(SystemRoot)System32Wbem;$(SystemRoot)System32WindowsPowerShellv1.0;$(ExecutablePath)

answered Jul 26, 2019 at 10:56

user27221's user avatar

user27221user27221

3343 silver badges16 bronze badges

How do I set a path for DLL files to be searched in Visual Studio for a particular project alone?

Now I am setting it in the environment path variable, but I would like better control over this.

Peter Mortensen's user avatar

asked Jan 9, 2009 at 13:46

yesraaj's user avatar

4

Search MSDN for «How to: Set Environment Variables for Projects». (It’s Project>Properties>Configuration Properties>Debugging «Environment» and «Merge Environment» properties for those who are in a rush.)

The syntax is NAME=VALUE and macros can be used (for example, $(OutDir)).

For example, to prepend C:WindowsTemp to the PATH:

PATH=C:WINDOWSTemp;%PATH%

Similarly, to append $(TargetDir)DLLS to the PATH:

PATH=%PATH%;$(TargetDir)DLLS

CharlesB's user avatar

CharlesB

84.4k27 gold badges189 silver badges214 bronze badges

answered May 26, 2010 at 19:28

Multicollinearity's user avatar

6

You have a couple of options:

  • You can add the path to the DLLs to the Executable files settings under Tools > Options > Projects and Solutions > VC++ Directories (but only for building, for executing or debugging here)
  • You can add them in your global PATH environment variable
  • You can start Visual Studio using a batch file as I described here and manipulate the path in that one
  • You can copy the DLLs into the executable file’s directory :-)

Community's user avatar

answered Jan 9, 2009 at 14:26

Timo Geusch's user avatar

Timo GeuschTimo Geusch

24k5 gold badges51 silver badges70 bronze badges

5

If you only need to add one path per configuration (debug/release), you could set the debug command working directory:

Project | Properties | Select Configuration | Configuration Properties
| Debugging | Working directory

Repeat for each project configuration.

Jorgesys's user avatar

Jorgesys

123k23 gold badges328 silver badges264 bronze badges

answered May 9, 2009 at 16:49

sean e's user avatar

sean esean e

11.7k3 gold badges43 silver badges56 bronze badges

Set the PATH variable, like you’re doing. If you’re running the program from the IDE, you can modify environment variables by adjusting the Debugging options in the project properties.

If the DLLs are named such that you don’t need different paths for the different configuration types, you can add the path to the system PATH variable or to Visual Studio’s global one in Tools | Options.

answered Jan 9, 2009 at 14:19

Mr Fooz's user avatar

Mr FoozMr Fooz

107k5 gold badges70 silver badges101 bronze badges

None of the answers solved exactly my problem (the solution file I was running was trying to find xcopy to copy a dll after generation).

What solved it for me was going into menu «Project -> Properties»

Then in the window that opens choosing on the left pane: «Configuration Properties -> VC++ Directories

On the right pane under «General» choosing «Executable Directories «

And then adding:

$(SystemRoot)system32;$(SystemRoot);$(SystemRoot)System32Wbem;$(SystemRoot)System32WindowsPowerShellv1.0;$(ExecutablePath)

answered Jul 26, 2019 at 10:56

user27221's user avatar

user27221user27221

3343 silver badges16 bronze badges

Man, have I struggled with this. Unfortunately there isn’t a one click solution in Visual Studio, but if you’re running Visual Studio 2012 and your project is under source control with Team Foundation Server, here is how I got it to work, while keeping the source history:

(Make sure you read @mjv’s comment below, as he notes that you can skip step 5-10)

  1. Make sure you have checked in all changes, so you have no pending changes.
  2. Remove the project from the solution, by right clicking and selecting Remove.
  3. Now, in Windows Explorer, rename the project folder.
  4. Go back to Visual Studio, and in Solution Explorer, right click the solution and choose Add -> Existing project. Select the project file for the project you removed in step 2, which should be located in the renamed folder.
  5. Now the project is back in the solution, but the project doesn’t seem to be added to source control. To fix that, open Source Control Explorer.
  6. Find the project folder in Source Control Explorer, that corresponds with the project folder on your disk, that you renamed in step 3.
  7. Rename the folder in Source Control Explorer, so it has the same name as the project folder on disk.
  8. Now take a look at your pending changes. You should have changes to the solution file and a rename operation on the project folder.
  9. Do a rebuild and make sure everything compiles correctly. If you had inter-project references to the project you renamed, you need to add them again to the individual projects that referenced it.
  10. You should be all set now. Go and check everything in.

The above guide worked for me. If it doesn’t work for you, try and delete your local solution completely, and remove the folder mapping in your workspace. Restart Visual Studio just in case. Make sure you actually deleted the whole solution from your computer. Now readd the solution mapping to your workspace and get the latest version. Now try the above steps. The same applies if something goes wrong while following the above steps. Just delete your solution locally and get the latest source, and you’ll have a clean slate to work with.

If you’re still having problems, make sure that you haven’t changed anything manually in the solution file, or trying other ‘tricks’ before trying the above steps. If you have changed something and checked it in, you might want to consider doing a rollback to the point just before you started messing with the renaming of the project.

Of course, you’d also want to rename the project itself, in Solution Explorer. You can do this before the steps above, but in that case, make sure you check in that change before applying the steps above. You can also do it afterwards, but make sure you follow all the steps above first, and check in your changes before trying to rename the project name in Solution Explorer. I don’t recommend trying to mix the above steps with a rename of the project name in Solution Explorer. It might work though, but I would recommand doing it in 2 separate changesets.

0 / 0 / 0

Регистрация: 16.05.2016

Сообщений: 2

1

Изменить путь в проекте

16.05.2016, 22:49. Показов 25197. Ответов 4


Переделывал проект под себя,всё как нужно,через рефакторинг,однако в пути осталась ПапкаY старого владельца. непосредственно через экзешник прога работает,однако при запуске проекта-ошибка пути,его нужно изменить,подскажите как,спасибо.

C:UsersZverDocumentsVisual Studio 2012ProjectsПапкаХПапкаY : error : не удалось загрузить файл проекта. Не удалось найти часть пути «C:UsersZverDocumentsVisual Studio 2012ProjectsПапкаХПапкаY. C:UsersZverDocumentsVisual Studio 2012ProjectsПапкаХПапкаY

__________________
Помощь в написании контрольных, курсовых и дипломных работ, диссертаций здесь



0



8 / 8 / 2

Регистрация: 21.01.2015

Сообщений: 34

17.05.2016, 08:45

2

Лучший ответ Сообщение было отмечено Ray-z как решение

Решение

Я неоднократно переименовывал/переносил проекты. Делал так: переименовать проект в студии, закрыть солюшен, переименовать папку проекта, в текстовом редакторе в файле sln изменить путь.



4



0 / 0 / 0

Регистрация: 16.05.2016

Сообщений: 2

17.05.2016, 11:06

 [ТС]

3

Спасибо большое,по переименовывал в блокноте всё,что можно,а sln видимо пропустил,всё работает,спасибо)



0



1 / 1 / 1

Регистрация: 17.07.2016

Сообщений: 20

17.09.2016, 22:01

4

А как путь к форме изменить ?



0



Администратор

Эксперт .NET

15251 / 12289 / 4905

Регистрация: 17.03.2014

Сообщений: 24,888

Записей в блоге: 1

17.09.2016, 22:38

5

Александр92, если речь о неправильном пути из-за которого проект не хочет открываться, то его можно исправить в csproj файле. Если ошибок нет, то файлы можно переносить в solution explorer.



0



Понравилась статья? Поделить с друзьями:
  • Как изменить favicon xenforo
  • Как изменить dns записи на reg ru
  • Как изменить favicon wordpress
  • Как изменить dns адрес на телевизоре lg
  • Как изменить fat32 на fat64