Skip to content
Tags

Surprising MSB4057 error

May 14, 2015

I have a solution, MySolution.sln, with several c# project (MyProj.csproj, My.Other.Proj.csproj)

This works:

msbuild MySolution.sln /nologo /t:MyProj

But this fails with MSB4057 (the target does not exist in the project):

msbuild MySolution.sln /nologo /t:My.Other.Proj

So, what could possibly be the difference between the two projects?

The dots!

There are two solutions for this:

1. replace the dot with underscore in the command-line (found in this thread). I wonder who was the first person who actually figured it out, and how.

msbuild MySolution.sln /nologo /t:My_Other_Proj

2. replace the internal project name in the .sln file to something without dots, and use it:

From:

Project(“{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}”) = “My.Other.Proj”, “My.Other.Proj.csproj”, “{DAAA327B-E461-4BC0-A331-D32208C1D94C}”

To:

Project(“{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}”) = “MyOtherProj”, “My.Other.Proj.csproj”, “{DAAA327B-E461-4BC0-A331-D32208C1D94C}”

Then build using the new, non-dotted name:

msbuild MySolution.sln /nologo /t:MyOtherProj

Thank you again, Microsoft, for keeping me busy with your unexplained, undocumented, and non-intuitive little features.

Advertisements
One Comment

Trackbacks & Pingbacks

  1. vSphere PowerCLI Fails to Launch | Adventures in SCM

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: