Reputation: 61
As i have tried to restructure the path using the ..\
in the csproj file after building the project
it still shows the error as stated after building the project here is the error below.
Also i have complete package for Microsoft.Net.Compilers.props as per the path which i have checked in the system where project resides, here is the path of the project below.
Now if I put ..\
or without it still won't find the path of the system here is the code after unloading the .csproj file below.
<Import Project="..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.8\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.8\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" />
<Import Project="..\packages\Microsoft.Net.Compilers.2.4.0\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.2.4.0\build\Microsoft.Net.Compilers.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
Upvotes: 3
Views: 5429
Reputation: 1
This is a classic mistake that occurs when you add packages and then, to optimize, you add them to other projects. Then, you remove the packages or give your partial solution to a colleague who doesn't have them.
Unfortunately, the path is not removed from the csproj
when you remove them, so proceed as follows:
Open the csproj
(or project)
Remove both the "Import Project=[...]
" paths and the "<Error Condition="!Exists('..[...]
"
If the problem persists, it's strange. Make sure that the appropriate package is present in that project.
Upvotes: 0
Reputation: 23808
The missing file is packages\Microsoft.Net.Compilers.2.4.0\build\Microsoft.Net.Compilers.props
First, glad to know that you have solved your issue by yourself.
Actually, this target node is from a file packages\Microsoft.Net.Compilers.2.4.0\build\Microsoft.Net.Compilers.props
which is in your nuget package and it will add a target called EnsureNuGetPackageBuildImports
into your xxx.csproj
file when you install Microsoft.Net.Compilers
nuget package.
Besides, since you have changed the default <Error Condition="xxxx">
node under this target due to some reasons(maybe migrate this project from somewhere into your new agent), the nuget mechanism does not recognize it and when you want to uninstall this package, the node cannot be deleted automatically, it can only be modified manually.
In addition, the Error task in MSBuild is equivalent to interrupting the construction generation based on certain judgment conditions. Therefore, in your current environment, that is, if you cannot find the specified Microsoft.Net.Compilers.props
file, you cannot build your project.
Suggestion
1) So to solve it, you can just edit the condition to the correct path of Microsoft.Net.Compilers.props
as you did.
<Error Condition="!Exists('..\packages\Microsoft.Net.Compilers.2.4.0\build\Microsoft.Net.Compilers.props')" xxxx />
2) Or if your project has a lot of that, I suggest you could first delete these targets in xxx.csproj
file and then run update-package -reinstall
under Tools
-->Nuget Package Manager
-->Package Manager Console
.
And this will reshape the nuget package according to the current environment and it can also fix DLL addresses that reference the wrong DLL and so on.
Upvotes: 3