I ran into a problem with MSBuildI can’t overcome it myself. As a result, I rely on community wisdom.
In a real situation, I have problems with
I have a soluiton file containing several projects with dependencies for other projects in one solution. I would like to add a custom target to one of the csproj project files and build it from the command line. This will allow me to make all the necessary output binaries for this project for further processing during the creation of the custom target. But most importantly, I can’t figure out how to do this, googling doesn’t help either.
Relief
To simplify the task, I decided to create a new C # console project, add a simple custom target to the project file and try to create it. And yet no success! Here is what I have done so far:
An application application with the default coreapp console project has been created. This gives me at least two files:
- app.sln
- coreapp \ coreapp.csproj
Modified coreapp.csproj with the addition of my custom target inside the Project tag
<Target Name="SampleTarget">
<Message Text="This is a SampleTarget" />
</Target>
Run the following command at a command prompt
%windir%\Microsoft.NET\framework\v3.5\msbuild.exe app.sln /t:coreapp:SampleTarget
or even
%windir%\Microsoft.NET\framework\v3.5\msbuild.exe app.sln /t:coreapp.csproj:SampleTarget
results
Unlucky encountering an error
MSB4057: The target "coreapp.csproj:SampleTarget" does not exist in the project.
I suspect that he MSBuildthinks that something is fundamentally different from what I want him to think ...
BEsides, MSBuildEmitSolution = 1, msbuild , . . , , msbuild coreapp.proj, Target SampleTarget.
, SampleTarget , , SampleTarget?
!