When I build a web project from command-line using msbuild and no special parameters, it seems to build just fine, including calling an nswag task to build TS files.
When I build the same web project with the /p:DeployOnBuild=true parameter and the /p:PublishProfile parameter set, nswag is not called at all, and the build fails because none of the TS files were built.
Isn't using the DeployOnBuild parameter additive? Shouldn't any build tasks specified in the csproj file still get executed?
Using the Structured Log Viewer for MSBuild I was able to determine why MSBuild seemed to be skipping the NSwag task specified in my csproj file when DeployOnBuild=true.
Build order matters!
In our project we build a client TS file at build time and then at the end run yarn tsc to build out all of the JS files.
Wnen we add DeployOnBuild=true, early in the build process, it attempts to copy the JS files to the package folder. But because client TS file hadn't been built yet and the JS file created from it, the build was failing and never even getting to the NSwag command.
Related
I have configured a TFS(2017) build pipeline to compile a VS extension with debug mode for a specific requirement which require .pdb files.
The build solution task fails for "debug" configuration with below error, however same pipeline works for the release configuration.
I have tried the approach mentioned in the following discussion as well, howewer it doesn't resolve my issue.
https://social.msdn.microsoft.com/Forums/vstudio/en-US/fd220999-5761-475a-bf86-98dff6b35218/unable-to-compile-vsix-project-that-is-a-part-of-my-solution-using-amd64-msbuild-from-vs2015?forum=msbuild
Appreciate if someone can help me to resolve this issue.
Following is the build configuration used for the Build Solution task:
Following build variables are used to configure build parameters.
Build Error message:
packages\Microsoft.VSSDK.BuildTools.15.1.192\tools\VSSDK\Microsoft.VsSDK.targets
(633, 5)
packages\Microsoft.VSSDK.BuildTools.15.1.192\tools\VSSDK\Microsoft.VsSDK.targets(633,5):
Error VSSDK1077: Unable to locate the extensions directory. "Value
cannot be null. Parameter name: path1". Process 'msbuild.exe' exited
with code '1'.
Update your Microsoft.VSSDK.BuildTools NuGet package to latest version 15.9.3032, just in case it is a problem already solved.
Release configurations can also generate PDB files (Project properties, Build tab, Advanced...button, Output > Debugging information). So, if the Release configuration works for you, you can keep using it while also generating a pdb file with full debug information.
The error is happening when, once compiled correctly, the generated VSIX output file is going to be deployed to the folder for extensions of the experimental VS instance, which is a required step to debug the VSIX file. A possible explanation of the different behavior for Debug/Release configurations is that maybe your .csproj specifies <DeployExtension>False</DeployExtension> for the Release configuration. By default, if not set, that property is set to true in the Microsoft.VsSDK.targets file:
<DeployExtension Condition="'$(DeployExtension)' == ''">true</DeployExtension>
Since likely you don't need to deploy the VSIX to the VS experimental instance when building on a build server (because you are not going to debug it), you can set that property to False to skip the deployment. This can be done with a 3rd build configuration (ex: "DebugBuildServer"), for which you specify DeployExtension to False in the .csproj file, or sticking to two build configurations but passing the /p:DeployExtension=false in the MSBuild arguments of the Visual Studio Build task of your build pipeline.
I have a project that imports a certain targets file from a Nuget package. Even though I use PackageReferences I am forced to import this file manually.
(See my other question for details - How are we supposed to execute package build targets in the new world where nuget packages are consumed through msbuild PackageReference?)
This targets file injects chromedriver.exe into the Content item group with CopyToOutputDirectory = PreserveNewest.
I observe a situation where chromedriver.exe is not copied to the bin folder when running msbuild /t:"Restore;Build", but it is copied when running the two targets separately - msbuild /t:Restore; msbuild /t:Build.
Can anyone explain how this happens?
(I killed a good portion of the day learning the difference on my skin, want to know how come?)
Restore changes the imported project files in the obj\ directory.
For this to take effect, the project file needs to be re-evaluated entirely, which does not happen when you run the Restore and Build targets in the same invocation.
Use the -restore command line switch for MSBuild to run a Restore before the other specified targets in the same command line call. MSBuild will run the Restore, empty its XML caches and re-evaluate the project again when running the requested build.
I have a Class Library Project which contains t4 templates that execute on build. The output .sql files are set to Content of the .csproj and should be copied on build to the output folder.
I have the following configuration setup on my TeamCity Build Box using MSBuild:
Command line parameters:
/p:OutDir=C:\output\DBMigration
/p:Configuration=Release
/p:DebugSymbols=false
/p:DebugType=None
/p:DeleteExistingFiles=true
/t:rebuild
/verbosity:n
The output of this is that the files are copied to the outputdir but are deleted in the CoreClean step of the rebuild.
To get around this I can run a Build instead of a rebuild, (ie. /t:build).
This will skip the CoreClean step, but why is the CoreClean called on the output dir after the Copy process has taken place? Should the Delete action not be before the Copy?
And why do I only need to do this step for ClassLibrary type projects, web/windows applications do not seem to have this problem with the rebuild.
Also it appears from the build log that the output directory is never cleaned by /p:DeleteExistingFiles=true.
I could do a hack and force a powershell script to run to clean the directory before attempting to build, but there must be a supported MSbuild parameter to do this in the absence of the rebuild preforming correctly?
Issue: When building a UWP using the VSTS build service no .appxupload file for store submissions is created.
What I did: I created a build definition using the Universal Windows App template that contains 4 build steps. Apart from setting the repository to my external Git repository I didn't change anything.
After the build finishes I only have the _Test folder in my drop. No .appxupload file.
What I tried so far:
According to Build your Universal Windows Plattform app I have to add the UapAppxPackageBuildMode (set to CI) switch to the MSBuild arguments. I did it exactly as shown there. However, neither the .appxupload nor the _Test folder are created but the build step itself completes successfully. (Actually, the AppxPackages folder that is specified by default using the AppxPackageDir switch is missing, too)
I tried running the Create App Packages... option from within Visual Studio. This results in both, the .appxupload and _Test folder.
[Update] I found another switch to try at the MSBuild arguments which is AppxPackageIsForStore (set to true). This will generate the _Test folder but still not .appxupload package.
I could reproduce your issue. If don't use argument /p:UapAppxPackageBuildMode=CI, I could only get _Test folder. If add argument /p:UapAppxPackageBuildMode=CI, I'll get error message during Publish Artifact step:
Not found PathtoPublish: C:\a\1\b\AppxPackages
But I just tried argument /p:UapAppxPackageBuildMode=StoreUpload, it can generate both _Test folder and .appxupload file, you may have a try.
I know that msbuild does not support VDPROJ files, but it maybe built using command line devenv.
I want to build all prjects (C#) using msbuild task and only after that starting specific setup project from my solution. Of course this projects has dependencies to previously created C# projects (otput from proj1, proj2, proj3).
How could I do it?
Override AfterCompile (or AfterBuild) task and add Exec command for devenv.exe to compile vdproj files. When you run devenv.exe /build /project you will only build the specified project within the specified solution. Only project files that have changed since the last build will be build. Therefore the dependant projects will not be build unless they have been changed.