question

PerrettDuncan-7852 avatar image
0 Votes"
PerrettDuncan-7852 asked PerrettDuncan-7852 answered

How to add source files when debugging a Linux program with Visual Studio 2019 and GCC for Remote Linux

I have a remote Ubuntu VM with my source code, makefile and resultant program on it.
I have a Windows machine with VS2019 and I am trying to remotely debug the program.
The source code is not currently on the Windows machine at all.
I have created an Empty C++ Linux project.
The SSH connection is working and the Connection Manager seems happy.
The program can be started and the Linux Console shows the program running.

I cannot work out how to add the files so that I can then add breakpoints to them.
Previously when I was using WSL2 I was able to "Add Existing Item" and then browse on my U: (for Ubuntu) wsl drive or \\wsl$.

I have read about the Property called Copy Sources https://docs.microsoft.com/en-us/cpp/linux/prop-pages/copy-sources-project?view=msvc-160
but I'd rather not edit the vcxproj file to copy files from Windows to Ubuntu if possible.

Any ideas please?



vs-debugging
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.

DylanZhu-MSFT avatar image
0 Votes"
DylanZhu-MSFT answered PerrettDuncan-7852 commented

Hi PerrettDuncan,

You can try to specified your file path in Project Properties Page/Copy Sources/Additional Sources To Copy
90554-image.png

Best Regards,
Dylan


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.


image.png (21.1 KiB)
· 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.

OK I'll try.
The docs say -
Specifies additional sources to copy to the remote system. Optionally specify local to remote mapping pairs using a syntax like this: fulllocalpath1:=fullremotepath1;fulllocalpath2:=fullremotepath2, where a local file can be copied to the specified remote location on the remote system.

So does that mean I have to specify every individual file?
Ideally it would be nice to just point to a local folder and say *.cpp.

0 Votes 0 ·
PerrettDuncan-7852 avatar image
0 Votes"
PerrettDuncan-7852 answered

In reference to the "Remote Copy Source Method" -
How does rsync work for Visual Studio in Windows?
Have Microsoft got their own rsync implementation hidden in VS2019?
Or do they just rely on WSL?

FWIW I've decided to do the synchronising myself in scripts rather than rely on Visual Studio to do it for me.
My scripts use rsync with ssh from WSL.

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.