The "SignFile" task was not given a value for the required parameter "CertificateThumbprint" - msbuild

We have a line of business app which is deployed via clickonce. I can build and publish the application without any problems but when I try to use Continuous Integration (Build each check-in) I get the following error:
2>C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets(3450,5):
error MSB4044:
The "SignFile" task was not given a value for the required parameter "CertificateThumbprint".
[C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse\Pulse.csproj]
Done executing task "SignFile" -- FAILED.
We sign the application (to be more specific: the ClickOnce manifest) using a code signing certificate which is registered in the AD as Trusted Publisher.
The Certificate is stored in Certificate store on my local workstation. The Certificate is also in the certificate store of the build server (1. In the Personal Store, 2. in the Personal store of the TFSBuildServiceHost Service Account and 3. in the Personal store of the tfs/build server itself).
Where are using Visual Studio 2013 Update 4, C#, .Net 4.5 and TFS 2013 Update 4.
I have no clue what causes this error, any help is appreciated.
EDIT:
I forgot to mention that the tfs build worked fine a few weeks ago. I didn't change a thing, i verified that the project file (Pulse.csproj) hasn't changed and i also had a few successful builds with that exact Pulse.csproj file / build definition. I'm pretty sure that it must be something on the tfs server. I remember that Microsoft had some trouble with some updates regarding the certificate infrastructure could it be related?
EDIT 2:
I tried to build the project via command line using this command:
"C:\Program Files (x86)\MSBuild\12.0\bin\amd64\MSBuild.exe" C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse.sln
The build fails with the following message:
CleanPublishFolder: Removing directory "bin\Debug\app.publish\".
_DeploymentComputeClickOnceManifestInfo: Creating directory "bin\Debug\app.publish".
Copying file from "obj\Debug\Pulse.exe" to
"bin\Debug\app.publish\Pulse.exe". C:\Program Files
(x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets(3450,5):
error MSB3482: An error occurred while signi ng: SignTool.exe not
found. [C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse\Pulse.csproj]
Done Building Project
"C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse\Pulse.csproj" (default
targets) -- FAILED.
Done Building Project
"C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse.sln" (default targets)
-- FAILED.
Build FAILED.
"C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse.sln" (default target)
(1) -> "C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse\Pulse.csproj"
(default target) (2) -> (_DeploymentComputeClickOnceManifestInfo
target) -> C:\Program Files
(x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets(3450,5):
error MSB3482: An error occurred while sig ning: SignTool.exe not
found. [C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse\Pulse.csproj]
0 Warning(s)
1 Error(s)
The Signtool definitely exists on the Server. The path to the signtool is: "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Bin\signtool.exe" and "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\signtool.exe"
The most interesting part is that I CAN build the solution using a different msbuild tool.
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe"
C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse.sln
EDIT 3:
I installed the Windows Software Development Kit (SDK) for Windows 8 and now I can build the solution via command line. Thus, the code signing certificate is installed & available.
But the TFS Build fails.
Here is the error output gathered from the tfsbuild logfile:
Task "AL"
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\x64\AL.exe /culture:de /out:obj\Debug\de\Pulse.resources.dll /platform:AnyCPU /template:obj\Debug\Pulse.exe /embed:obj\Debug\Pulse.View.Localization.CreditsView.de.resources /embed:obj\Debug\Pulse.View.Localization.PulseMainWindow.de.resources
Microsoft (R) Assembly Linker version 12.0.20806.33440
Copyright (C) Microsoft Corporation. All rights reserved.
Done executing task "AL".
2>Done building target "GenerateSatelliteAssemblies" in project "Pulse.csproj".
2>Target "CreateSatelliteAssemblies" in file "C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets" from project "C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse\Pulse.csproj" (target "CoreBuild" depends on it):
2>Done building target "CreateSatelliteAssemblies" in project "Pulse.csproj".
Target "SetWin32ManifestProperties" skipped. Previously built successfully.
Target "_DeploymentComputeNativeManifestInfo" skipped, due to false condition; ('$(GenerateClickOnceManifests)'!='true') was evaluated as ('true'!='true').
2>Target "CleanPublishFolder" in file "C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets" from project "C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse\Pulse.csproj" (target "_DeploymentComputeClickOnceManifestInfo" depends on it):
Task "RemoveDir" skipped, due to false condition; ('$(PublishDir)'=='$(OutputPath)app.publish\' and Exists('$(PublishDir)')) was evaluated as ('bin\Debug\app.publish\'=='bin\Debug\app.publish\' and Exists('bin\Debug\app.publish\')).
2>Done building target "CleanPublishFolder" in project "Pulse.csproj".
Target "_DeploymentGenerateTrustInfo" skipped, due to false condition; ('$(TargetZone)'!='') was evaluated as (''!='').
2>Target "_DeploymentComputeClickOnceManifestInfo" in file "C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets" from project "C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse\Pulse.csproj" (target "GenerateApplicationManifest" depends on it):
Task "Copy"
Creating directory "bin\Debug\app.publish".
Copying file from "obj\Debug\Pulse.exe" to "bin\Debug\app.publish\Pulse.exe".
Done executing task "Copy".
Using "SignFile" task from assembly "Microsoft.Build.Tasks.v12.0, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
Task "SignFile"
2>C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets(3450,5): error MSB4044: The "SignFile" task was not given a value for the required parameter "CertificateThumbprint". [C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse\Pulse.csproj]
Done executing task "SignFile" -- FAILED.
2>Done building target "_DeploymentComputeClickOnceManifestInfo" in project "Pulse.csproj" -- FAILED.
2>Target "_CheckForCompileOutputs" in file "C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets" from project "C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse\Pulse.csproj" (target "_CleanGetCurrentAndPriorFileWrites" depends on it):
2>Done building target "_CheckForCompileOutputs" in project "Pulse.csproj".
Target "_SGenCheckForOutputs" skipped, due to false condition; ('$(_SGenGenerateSerializationAssembliesConfig)' == 'On' or ('#(WebReferenceUrl)'!='' and '$(_SGenGenerateSerializationAssembliesConfig)' == 'Auto')) was evaluated as ('Off' == 'On' or (''!='' and 'Off' == 'Auto')).
2>Target "_CleanGetCurrentAndPriorFileWrites" in file "C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets" from project "C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse\Pulse.csproj" (target "_CleanRecordFileWrites" depends on it):
Task "ReadLinesFromFile"
Done executing task "ReadLinesFromFile".
Task "ConvertToAbsolutePath"
Done executing task "ConvertToAbsolutePath".
Task "FindUnderPath"
Comparison path is "C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse".
Done executing task "FindUnderPath".
Task "FindUnderPath"
Comparison path is "C:\Builds\1\Pulse\DefaultBuild\bin\".
Done executing task "FindUnderPath".
Task "FindUnderPath"
Comparison path is "obj\Debug\".
Done executing task "FindUnderPath".
Task "RemoveDuplicates"
Done executing task "RemoveDuplicates".
2>Done building target "_CleanGetCurrentAndPriorFileWrites" in project "Pulse.csproj".
2>Target "_CleanRecordFileWrites" in file "C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets" from project "C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse\Pulse.csproj" (target "CoreBuild" depends on it):
Task "RemoveDuplicates"
Done executing task "RemoveDuplicates".
Task "MakeDir"
Done executing task "MakeDir".
Task "WriteLinesToFile"
Done executing task "WriteLinesToFile".
2>Done building target "_CleanRecordFileWrites" in project "Pulse.csproj".
2>Done Building Project "C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse\Pulse.csproj" (default targets) -- FAILED.
1>Done executing task "MSBuild" -- FAILED.
1>Done building target "Build" in project "Pulse.sln" -- FAILED.
1>Done Building Project "C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse.sln" (default targets) -- FAILED.
Build FAILED.
"C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse.sln" (default target) (1) ->
"C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse\Pulse.csproj" (default target) (2) ->
(_DeploymentComputeClickOnceManifestInfo target) ->
C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets(3450,5): error MSB4044: The "SignFile" task was not given a value for the required parameter "CertificateThumbprint". [C:\Builds\1\Pulse\DefaultBuild\src\Pulse\Pulse\Pulse.csproj]
0 Warning(s)
1 Error(s)
EDIT 4:
Visual Studio 2013 is not installed on our build server. I've already been through the logfile and found that the TFS Build uses the MSBuild.exe stored in C:\Program Files (x86)\MSBuild\12.0\bin\amd64\ .
Since I can build the project on the build server using the MSBuild.exe than TFS Build does I can be sure that the certificate itself is not an issue.
I created a new build definition without modifying any of the settings but I still get the same error message.
I also repaired the TFS Installation on the build server but no luck.
I compared all *.targets files stored in the C:\Program Files (x86)\MSBuild\12.0\bin\amd64\ Folder on the Server with the *.targets files in the same location on my client machine. There 100% identical.
Needless to say that I can build the project without any problems on my client machine (via VS2013 and command line).
I deleted and re-registered/created the build service/controller/agent. The result is still the same.
I'm stuck here. Any ideas?

Note: If you are looking for a quick fix and it is okay for your project to not be signed then you can do this. I encounter this problem when I am looking for a sample code, and using this quick fix solves my problem instantly.
Go to the project properties
Select signing options
Uncheck the `Sign the ClickOnce manifests
Save
Re-run it
(Optional) In some cases you need to rebuild it.
If it doesnt work please try to uncheck the enable ClickOnce security settings which can be located on Security tab.

This is how I solved the problem:
Our build services was configured to run as NT AUTHORITY\NetworkService I simply changed this to my own user account. Note that I already had the *.pfx file installed to personal certificate store.
I guess the problem was that the user NT AUTHORITY\NetworkService does not have the required certificate in the certificate store. I still have no idea how to add certificates into the personal store of system accounts. Nevertheless my problem is gone for now although I don't like the fact that the build service runs with my credentials.

try to add the certificate in the signing tab of the project properties by selecting "Select from store"
or
try clicking "Create Test Certificate"...

Another reason why you might be getting this is if the certificate thumbprint has changed (i.e. when it has been renewed because the old certificate has expired), and you no longer have the old certificate installed. This happened to me just now.
Solution: open up the project in Visual Studio, go to the Signing Tab, click Select from Store and make sure that the correct (new) certificate is installed. This solved the problem for me.

For those come across this issue using CI with an EV Code Signing Certificate. EV Code Signing Certificates use a dongle or thumb drive, so you must have a build server on premise and update your project file manually.
In VS, Right click on your project and Unload it.
Right click and Edit the csproj file.
Find or add this entry
<PropertyGroup>
<ManifestCertificateThumbprint>**Your Certificate Thumbprint Here**</ManifestCertificateThumbprint>
</PropertyGroup>
Copy and paste the thumbprint of the certificate from your build server
into the ManifestCertificateThumprint value.
Reload your project
and check in.

when i had this issue i edited the .csproj file using a text editor.
i remove the "ManifestCertificateThumbprint", "ManifestKeyFile" , "GenerateManifests" and
"SignManifests" propertyGroup.
Goodluck!!

I had the same issue. I sorted it out in rather weird way. I went to the project properties then selected 'Signing' option. Under it I unchecked the Sign the ClickOnce manifests and also unchecked the Sign the assembly option. The project ran afterwards.
This is a dangerous solution and is not offered as a permanent solution.In my case I used it only because I was working on a local copy and needed to do some fixes so I just needed to get the project to run. In a real world deployment scenario do not do this.

Related

Why is the project file not found even though I am using an MSBuild task?

I created an Azure Devops build pipeline and I am trying to build my ASP.NET MVC and Angular hybrid site project on Bitbucket (git).
The project first gets checked out, and Nuget restores the necessary packages, however, I cannot get the .NET to build!
I've stumbled on this post here that basically advises against using the dotnet build task and recommended just using Visual Studio build or MSBuild tasks instead.
Nether are working for me though!
I tried VS2017-win2016 hosted agent, didn't work.
I tried Windows 2019 hosted agent, didn't work.
I am getting this error:
Bobby.ProjectA\Bobby.ProjectA.csproj(713,3): Error MSB4019: The imported project "C:\Program Files\dotnet\sdk\5.0.100\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the expression in the Import declaration "C:\Program Files\dotnet\sdk\5.0.100\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets" is correct, and that the file exists on disk.
Error: The process 'C:\Program Files\dotnet\dotnet.exe' failed with exit code 1
Dotnet command failed with non-zero exit code on the following projects : D:\a\1\s\Bobby.ProjectA.Tests\Bobby.ProjectA.Tests.csproj,D:\a\1\s\Bobby.ProjectA\Bobby.ProjectA.csproj
D:\a\1\s\Bobby.ProjectA\BobbyProjectA\BobbyProjectA.sln.metaproj(0,0): Error MSB3202: The project file "D:\a\1\s\Bobby.ProjectA\BobbyProjectA\Bobby.ProjectA\Bobby.ProjectA.csproj" was not found.
D:\a\1\s\Bobby.ProjectA\BobbyProjectA\BobbyProjectA.sln.metaproj(0,0): Error MSB3202: The project file "D:\a\1\s\Bobby.ProjectA\BobbyProjectA\Bobby.ProjectA.Tests\Bobby.ProjectA.Tests.csproj" was not found.
Process 'msbuild.exe' exited with code '1'.
Since Ubuntu is faster, I also tried that, however, as expected Visual Studio build task fails with that since VS is not installed on the machine.
So I tried with MSBuild and that worked fine with Ubuntu, however, still getting same error that the project file was not found.
Project "/home/vsts/work/1/s/Bobby.ProjectA/BobbyProjectA/BobbyProjectA.sln" on node 1 (default targets).
ValidateSolutionConfiguration:
Building solution configuration "Debug|Any CPU".
/home/vsts/work/1/s/Bobby.ProjectA/BobbyProjectA/BobbyProjectA.sln.metaproj : error MSB3202: The project file "/home/vsts/work/1/s/Bobby.ProjectA/BobbyProjectA/Bobby.ProjectA/Bobby.ProjectA.csproj" was not found. [/home/vsts/work/1/s/Bobby.ProjectA/BobbyProjectA/BobbyProjectA.sln]
/home/vsts/work/1/s/Bobby.ProjectA/BobbyProjectA/BobbyProjectA.sln.metaproj : error MSB3202: The project file "/home/vsts/work/1/s/Bobby.ProjectA/BobbyProjectA/Bobby.ProjectA.Tests/Bobby.ProjectA.Tests.csproj" was not found. [/home/vsts/work/1/s/Bobby.ProjectA/BobbyProjectA/BobbyProjectA.sln]
Done Building Project "/home/vsts/work/1/s/Bobby.ProjectA/BobbyProjectA/BobbyProjectA.sln" (default targets) -- FAILED.
Build FAILED.
"/home/vsts/work/1/s/Bobby.ProjectA/BobbyProjectA/BobbyProjectA.sln" (default target) (1) ->
(Build target) ->
/home/vsts/work/1/s/Bobby.ProjectA/BobbyProjectA/BobbyProjectA.sln.metaproj : error MSB3202: The project file "/home/vsts/work/1/s/Bobby.ProjectA/BobbyProjectA/Bobby.ProjectA/Bobby.ProjectA.csproj" was not found. [/home/vsts/work/1/s/Bobby.ProjectA/BobbyProjectA/BobbyProjectA.sln]
/home/vsts/work/1/s/Bobby.ProjectA/BobbyProjectA/BobbyProjectA.sln.metaproj : error MSB3202: The project file "/home/vsts/work/1/s/Bobby.ProjectA/BobbyProjectA/Bobby.ProjectA.Tests/Bobby.ProjectA.Tests.csproj" was not found. [/home/vsts/work/1/s/Bobby.ProjectA/BobbyProjectA/BobbyProjectA.sln]
I pretty much exhausted my searches and not sure how to solve this.
Here are some screenshots that show my pipeline tasks:
I also thought maybe x64 architecture would have something to do with it, but that didn't resolve the issue.
I've stumbled on some other interesting posts like this one, but I'm not sure what adding the project to source control means in the answer given, considering my csproj files are already hosted in the repo and being checked out before any tasks run.
My project structure and .sln path (project):
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29806.167
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bobby.ProjectA", "Bobby.ProjectA\Bobby.ProjectA.csproj", "{12345FE4-4CB9-3245-9A45-DB9A4AF1DFEB}"
Based on my test, I could reproduce the similar issue when the wrong csproj file path is mapped in the .sln file.
You could check your .sln file -> project field.
For example:
File structure
The .csproj file is under the WebApplication2 folder, so the project relative path is WebApplication2\WebApplication2.csproj.
.sln file
VisualStudioVersion = 16.0.30611.23
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApplication2", "WebApplication2\WebApplication2.csproj", "{497AD76F-222C-4BEB-BDCB-401B0E80B5CE}"
EndProject
Update:
After discussion with Cataster, the import Project issue can be resolved by specifying **/*.csproj in Msbuild task.
For example:

Could not load file or assembly 'Microsoft.Build.Utilities.Core, Version=15.0.0.0

I am using VS2017, MSBuild version 15.0. I have been installing taichi(https://github.com/yuanming-hu/taichi) .I have been facing lots of errors and trying to solve each step by step and now I am stuck with the following error. I have MSbuid 15.0 but it is looking for version 4.0 .
Build FAILED.
"C:\Users\5000\Documents\spgrid_topo_opt-master\taichi-master\build\taichi.sln" (default target) (1) ->
"C:\Users\5000\Documents\spgrid_topo_opt-master\taichi-master\build\ZERO_CHECK.vcxproj" (default target) (2) ->
(SetTelemetryEnvironmentVariables target) ->
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\VC\VCTargets\Microsoft.Cpp.DesignTi
me.targets(491,5): error MSB4062: The "SetEnv" task could not be loaded from the assembly C:\Program Files (x86)
\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\VC\VCTargets\Microsoft.Build.CppTasks.Common.dll. Could not
load file or assembly 'Microsoft.Build.Utilities.Core, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f
7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask>
declaration is correct, that the assembly and all its dependencies are available, and that the task contains a p
ublic class that implements Microsoft.Build.Framework.ITask. [C:\Users\5000\Documents\spgrid_topo_opt-master\tai
chi-master\build\ZERO_CHECK.vcxproj]
0 Warning(s)
1 Error(s)
1.Please open Developer Command Prompt for VS2017(come with build tools) and type the build command like: msbuild ZERO_CHECK.vcxproj
2.Check if it makes any difference,if same issue persists open vs installer and update the build tools to latest version. Then build the C++ project to check if it helps
I configured the similar environment like yours. And use the SetEnv task in .vcxproj file. But all works well when building the project.
So if all above can't work to resolve the issue: There is possibility that you call msbuild programmatically in code. If so, maybe you can get some help from this issue:
Try binding redirection, thanks to Nicolas.
Also, you can check this thread.
Any update feel free to contact me:)
Edit your PATH environment variable to ensure the first path to a directory containing msbuild.exe is the one included with Visual Studio 2017. This may be one of the following paths, depending on the edition you have and whether you installed it to the default location.
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\

MonoDevelop reports Build Successful but there is no exe file

In MonoDevelop, I create a new solution (C# console application).
It gives me a simple hello world program.
I press the run button.
I see "Build Successful"
The terminal comes up and says:
Cannot open assembly '/home/beauxq/MonoProjects/cstest/cstest/bin/Debug/cstest.exe': No such file or directory.
Press any key to continue...
I look in that bin/Debug directory and it is empty.
The build output:
Building: cstest (Debug|x86)
Build started 7/28/2016 9:29:40 AM.
__________________________________________________
Project "/home/beauxq/MonoProjects/cstest/cstest/cstest.csproj" (Build target(s)):
Target PrepareForBuild:
Configuration: Debug Platform: x86
Target GenerateSatelliteAssemblies:
No input files were specified for target GenerateSatelliteAssemblies, skipping.
Target GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because its outputs are up-to-date.
Done building project "/home/beauxq/MonoProjects/cstest/cstest/cstest.csproj".-- FAILED
Build FAILED.
0 Warning(s)
---------------------- Done ----------------------
Build successful.
The same happens when I select "Build" from the menu. "Build Successful" but the directory is empty.
It's nice to specify your linux/unix distribution. Or create the bug in their bugtracker. They will decide is it packaging problem or upstream problem. If this is upstream problem, maintainers will create bug in monodevelop bugtracker.

Command-line Package Service Fabric Application

Our continuous delivery set-up, until recently, was delivering Service Fabric packages using the following command:
msbuild SFApp.sfproj /t:Package
This was necessary because the target Package is unavailable at the solution level. I.e. The command
msbuild SFSolution.sln /t:Package
Fails, as the target does not exist.
As our dependency mesh grows, it gets to a point in which most interfaces projects will not build without a solution file (to work around the "OutputPath does not exist" red herring). There seems to be a way to do that according to this answer. Unfortunately, while targets like Clean work…
msbuild SFSolution.sln /t:SFApplication:Clean
(…snip…)
Build succeeded.
0 Warning(s)
0 Error(s)
…the target Package won't!
msbuild SFSolution.sln /t:SFApplication:Package
(…snip…)
Build FAILED.
"SFSolution.sln" (SFApplication:Package target) (1) -> SFSolution.sln.metaproj :
error MSB4057: The target "SFApplication:Package" does not exist in the
project. [SFSolution.sln]
0 Warning(s)
1 Error(s)
(Solution/project folders/names omitted/paraphrased for clarity. I can provide the actual logs if necessary.)
So the question is: how could I, using the Command Line, build one project using the Package target and the solution file?
Or how can I otherwise package a Service Fabric application from the command line?
It's bad idea to compile sfproj file(and any other project file) without sln, because it can bring wrong content to its output from referenced projects. Only solution has a knowledge about what project to compile in what configuration.
To make Package similar to "Right Click->Package" in VS:
Just add to your sfproj the following target
<Target Name="ForcePackageTarget" AfterTargets="Build" Condition="'$(ForcePackageTarget)' =='true'">
<CallTarget Targets="Package"/>
</Target>
And then running normal build on solution you may trigger the package step by /p:ForcePackageTarget=true :
msbuild yoursolution.sln /t:Build /p:ForcePackageTarget=true /p:Configuration=Release /p:Platform=x64
Actually it performs two-in-one steps, build and package, with respect to Solution Configurations on all referenced projects
MSBuild only supports a small set of target names that can be specified at the solution level. As you've discovered, Package is not one of them. You'll need to execute two separate calls to MSBuild: one which builds the solution and one which calls the Package target on the sfproj. The Package target of an sfproj has a dependency on the Build target so it will ensure that the sfproj and its project dependencies are built.
I had the same problem and fixed it by changing the Platform in the failing projects to explicitly build for x64.
Click Build > Configuration Manager and make sure that the assemblies are compiled for the x64 platform, that should also set the Output Paths in the corresponding .csproj files.
The actual command line action that is being executed is this:
"C:\Program Files (x86)\MSBuild\14.0\bin\amd64\msbuild.exe" "C:\agent\_work\1\s\Project\SFProject.sfproj" /t:Package /p:platform="x64" /p:configuration="release" /p:VisualStudioVersion="14.0"
Use the below script.
C:\Program Files (x86)\Microsoft Visual Studio 14.0> msbuild "Fabric.sfproj" /t:Package /p:Configuration=Release
Service fabric requires Target to be set in x64 platform,
So change all you reference projects target to x64 platform.
you can do this by using configuration properties of your solution. If x64 is not listed in 'Configuration Properties' click configuration manager in the same window and under platform column for the required project add new project platform as x64.
Hope this works for you.
We have had the exact same problem as you had and I have been looking around for a solution all over the web and did some experiments. Those are the steps that worked for us:
Don't manually add a target anywhere as suggested by other answers on StackOverflow. Not necessary. Especially in a CI environment, you want to build the projects separately anyways.
Prepare the projects in the Solution: Change the target platform for all projects to x64
Build the application
msbuild.exe SFAplication.xproj /p:Configuration=Release /target:rebuild
Package the App
msbuild.exe SFAplication.sfproj /p:Configuration=Release /target:Package

Microsoft.VisualStudio..Default.props" was not found

I've been searching around but what I got is something like
The imported project "C:...\Microsoft.Cpp.Default.props" was not found,
instead of
"C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Microsoft.VisualStudio..Default.props" was not found.". See the diff, the former is "Microsoft.Cpp.Default.props" while my error is Microsoft.VisualStudio..Default.props. Here's the full error log:
Path To MSBuild.exe: C:\Program Files (x86)\MSBuild\12.0\Bin\MSBuild
Executing the command cmd.exe /C " "C:\Program Files (x86)\MSBuild\12.0\Bin\MSBuild" /t:Build,Publish /p:Configuration=Release /p:platform=x86 "platforms\windows\CordovaApp.Windows.jsproj" " && exit %%ERRORLEVEL%% from E:\Jenkins\workspace\Mobile Field Service (Windows)
[Mobile Field Service (Windows)] $ cmd.exe /C " "C:\Program Files (x86)\MSBuild\12.0\Bin\MSBuild" /t:Build,Publish /p:Configuration=Release /p:platform=x86 "platforms\windows\CordovaApp.Windows.jsproj" " && exit %%ERRORLEVEL%%
Microsoft (R) Build Engine version 12.0.30501.0
[Microsoft .NET Framework, version 4.0.30319.34014]
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 11/26/2015 4:27:09 AM.
Project "E:\Jenkins\workspace\Mobile Field Service (Windows)\platforms\windows\CordovaApp.Windows.jsproj" on node 1 (Build;Publish target(s)).
E:\Jenkins\workspace\Mobile Field Service (Windows)\platforms\windows\CordovaApp.Windows.jsproj(52,5): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Microsoft.VisualStudio..Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
Done Building Project "E:\Jenkins\workspace\Mobile Field Service (Windows)\platforms\windows\CordovaApp.Windows.jsproj" (Build;Publish target(s)) -- FAILED.
Build FAILED.
"E:\Jenkins\workspace\Mobile Field Service (Windows)\platforms\windows\CordovaApp.Windows.jsproj" (Build;Publish target) (1) ->
E:\Jenkins\workspace\Mobile Field Service (Windows)\platforms\windows\CordovaApp.Windows.jsproj(52,5): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Microsoft.VisualStudio..Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.79
Build step 'Build a Visual Studio project or solution using MSBuild' marked build as failure
Archiving artifacts
Finished: FAILURE
By the way is it ok that my OS is Windows 2012 R2?
Check whether Microsoft.TypeScript.Default.props is available in the following location of your jenkins server
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\TypeScript
And if not
try to copy it from your local machine (if it is available in your local machine and your jenkins in a separate server) and create the required folder structure
OR
Add this conditional import statement in the project file
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.Default.props"
Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.Default.props')" />
I got the MSB4019 error because I did not have write permissions on C.
Executing the command with admin privileges helped in my case, but changing read/write permissions on C for your Windows user account should also work.
Other options are listed in this thread.