Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux Makefile project is not building from MSBuild (builds fine from Visual Studio) #5889

Open
abelykh0 opened this issue Nov 17, 2020 · 4 comments

Comments

@abelykh0
Copy link

abelykh0 commented Nov 17, 2020

Issue Description

Linux Makefile project is not building from MSBuild (builds fine from Visual Studio)

Steps to Reproduce

In Visual Studio add a remote connection (Tools > Options > Cross Platform > Connection Manager > Add)
In Visual Studio create a new "Makefile project"
Rename it to "myprog"

Add file main.cpp like this

#include "stdio.h"
int main()
{
	printf("Hello");
	return 0;
}

Add file makefile (no extension) like this (note, it needs real tabs, not replaced by spaces, otherwise you'd get "*** missing separator")

src = $(wildcard *.cpp)
obj = $(src:.c=.o)
x64/Debug/myprog: $(obj)
	$(CC) -o $@ $^ $(LDFLAGS)
.PHONY: clean
clean:
	rm -f $(obj) x64/Debug

In Project Propertied > Remote Build specify:
Build Command Line: make
Outputs: $(Platform)/$(Configuration)/myprog

Make sure project builds from Visual Studio
Delete bin and obj files from the project folder
Open "Developer Command Prompt for VS 2019", change current folder to the project folder, run the following command :

msbuild /property:Configuration=Debug /property:Platform=x64 /verbosity:normal .\myprog.vcxproj

It fails. Note, if the folder obj\x64\Debug exists (even empty), it works.

Expected Behavior

Should build

Actual Behavior

You will get the following output:

>msbuild /property:Configuration=Debug /property:Platform=x64 /verbosity:normal .\myproj.vcxproj
Microsoft (R) Build Engine version 16.8.1+bd2ea1e3c for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 17/11/2020 10:33:00 AM.
Project "C:\myproj\myproj.vcxproj" on node 1 (default targets).
_ValidateSources:
  Validating sources
_CopySources:
  Copying sources remotely to '*****'
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Application Type\Linux\1.0\Lin
ux.Makefile.Targets(261,5): error : Exception occured while copying sources to remote machine - Could not find a part o
f the path 'C:\myproj\obj\x64\Debug\1085594582.Local_Remote_PathMapping.tlog'. [C
:\Users\andreyb\source\repos\Project4\Project4\myproj.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Application Type\Linux\1.0\Lin
ux.Makefile.Targets(261,5): error : Could not find a part of the path 'C:\myproj\
obj\x64\Debug\1085594582.CopySourcesUpToDateFile.tlog'. [C:\myproj\myproj.vcxproj
]
Done Building Project "C:\myproj\myproj.vcxproj" (default targets) -- FAILED.


Build FAILED.

"C:\myproj\myproj.vcxproj" (default target) (1) ->
(_CopySources target) ->
  C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Application Type\Linux\1.0\L
inux.Makefile.Targets(261,5): error : Exception occured while copying sources to remote machine - Could not find a part
 of the path 'C:\myproj\obj\x64\Debug\1085594582.Local_Remote_PathMapping.tlog'.
[C:\myproj\myproj.vcxproj]
  C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Application Type\Linux\1.0\L
inux.Makefile.Targets(261,5): error : Could not find a part of the path 'C:\Users\andreyb\source\repos\Project4\Project
4\obj\x64\Debug\1085594582.CopySourcesUpToDateFile.tlog'. [C:\myproj\myproj.vcxpr
oj]

    0 Warning(s)
    2 Error(s)

Time Elapsed 00:00:01.87

Analysis

If I add the following workaround (modify project file), it starts to work:

  <Target Name="WorkaroundForMakefileIssue" BeforeTargets="_ConsolidateSourcesToCopy">
    <MakeDir Directories="obj\x64\$(Configuration)" />
  </Target>

Versions & Configurations

Microsoft (R) Build Engine version 16.8.1+bd2ea1e3c for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

16.8.1.52902

@abelykh0 abelykh0 added bug needs-triage Have yet to determine what bucket this goes in. labels Nov 17, 2020
@benvillalobos benvillalobos self-assigned this Nov 18, 2020
@abelykh0
Copy link
Author

@benvillalobos, do you have any update on this issue? ETA?

@xXTurnerLP
Copy link

This is a problem I had and still have, workaround is to kill MSBuild before each build (taskkill /f /im MSBuild.exe in cmd)

but i have a shit ton of other errors with nothing more than a stacktrace, msbuild is so fucking shit..

@benvillalobos benvillalobos removed the needs-triage Have yet to determine what bucket this goes in. label Apr 21, 2022
@benvillalobos
Copy link
Member

The workaround here is the solution I'd expect. MSBuild doesn't control the Linux.Makefile.Targets file. I see it's installed under VS, is this on the cpp side of things? @yuehuang010

It looks like ConsolidateSourcesToCopy could do an existence check on the output directory if it doesn't exist.

@benvillalobos benvillalobos removed their assignment Nov 15, 2022
@yuehuang010
Copy link
Contributor

@xXTurnerLP, to best reach the team, can you please create a ticket in DeveloperCommunity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants