dotnet / dotnet/msbuild

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

Open
#5,889 4 comments 2 reactions 0 assignees View on GitHub
bug triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 13h
Merged PRs (30d)
133

Description

### 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

```cpp
#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:
```xml



```

### 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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.