Generic Project and MSBuild

I would like to use "Generic Project" type to execute some tools during build. I know I can use msbuild targets to extend existing projects, but I would like to decouple it from existing projects. "Generic Project" type looks like it's meant exactly for that.

"Generic Project" creates an .mdproj file with the following content:

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Default</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ItemType>GenericProject</ItemType>
    <ProjectGuid>{6CB4E814-D016-431E-8D7C-63A4DD1DA245}</ProjectGuid>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Default|AnyCPU' ">
    <OutputPath>.\</OutputPath>
  </PropertyGroup>
</Project>

Fine, looks like an MSBuild project, with default target "Build". So I go ahead and add the "Build" target (added at the bottom). In this example, the Build target simply creates a file in /tmp.

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Default</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ItemType>GenericProject</ItemType>
    <ProjectGuid>{6CB4E814-D016-431E-8D7C-63A4DD1DA245}</ProjectGuid>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Default|AnyCPU' ">
    <OutputPath>.\</OutputPath>
  </PropertyGroup>
  <!-- edit here -->
  <Target Name="Build">
    <Touch AlwaysCreate="true" Files="/tmp/genericbuild.txt" />
  </Target>
</Project>

Now the problem is that Visual Studio for Mac is not executing that Target. Visual Studio says that it built the project successfully (right click on project, click build), but it definitely did not execute the Build target because the file is not created.
If I use MSBuild directly (via command line) everything works as expected.

For me it looks like that VS for Mac is not using MSBuild for the "Generic Project" type.

Any ideas/suggestions/workarounds?

Answers

  • mattwardmattward GBMember Xamurai

    Correct Visual Studio for Mac does not build generic projects with MSBuild.

    I would try creating a .csproj and override the build target so it does not try to compile anything.

Sign In or Register to comment.