I'm trying to set up CCNET and I've run into a problem.
My builds are failing and I'm getting this error
MSBUILD : error MSB1011: Specify which project or solution file to use because this folder contains more than one project or solution file.
In my configuration file ccnet.config my msbuild block is as follows
<msbuild>
<executable>C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe</executable>
<workingDirectory>C:\example\directory</workingDirectory>
<projectFile>ExampleSolution.sln</projectFile>
<buildArgs>/noconsolelogger /v:quiet
/p:Configuration=Debug
/p:ReferencePath="C:\Program Files (x86)\NUnit 2.5.10\bin\net-2.0\"
</buildArgs>
<targets>ReBuild</targets>
<timeout>600</timeout>
</msbuild>
In this case, C:\example\directory has multiple solution files. Even though I specified the project file I'm still getting that error.
You should specify what to build in the sln group.
msbuild SlnFolders.sln /t:NotInSolutionfolder:Rebuild;NewFolder\InSolutionFolder:Clean
So in CC.NET, add the /t parameter in the <buildArgs> tag.
Reference : http://msdn.microsoft.com/en-us/library/ms164311.aspx
Related
We are using Wixtoolset V3.9 to build our setup. We use the following command to start a build:
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\msbuild.exe" /restore /t:Rebuild /p:Configuration=Release /p:Platform=x64 MySolution.sln /p:BabelEnabled=true
We need the parameter /restore to restore the nuget-packagages on our build-server. Since we build our Wix-Setup by MSBUILD 16 we get the following warning:
Skipping restore for project 'SetupWix.wixproj'. The project file may be invalid or missing targets required for restore.
The warning belongs to category NU1503 (whatever this means). We cannot find a way to solve or even suppress this warning. We have tried to suppress it by adding the code NU1503 to the Project-Properties:
Whatever the reason, the warning still appears.
Question: How can we solve or suppress this warning?
TL;DR
You can get rid of NU1503 by including this in your .proj / msbuild file:
<!-- prevents NU1503 -->
<Target Name="_IsProjectRestoreSupported"
Returns="#(_ValidProjectsForRestore)">
<ItemGroup>
<_ValidProjectsForRestore Include="$(MSBuildProjectFullPath)" />
</ItemGroup>
</Target>
<Target Name="Restore" />
Source: https://github.com/NuGet/NuGet.Client/blob/537630019c99fdc7bed1b3dfdade72fc3e31692f/src/NuGet.Core/NuGet.Build.Tasks/NuGet.targets#L1286-L1298
Detailed explanation
I figured this out by inspecting the msbuild.binlog file via dotnet restore /bl with the awesome MSBuild Binary Log File Viewer tool.
The warning is generated by the WarnForInvalidProjectTask:
... which are generated by the _FilterRestoreGraphProjectInputItems target...
... which calls a _IsProjectRestoreSupported target, if there is one.
I have a C# solution with VS 2017, containing an app project and a test project. I can use the "create app package" wizard to create one single bundle for x86 and x64. However, I would like to automate this process, which means I need to use msbuild in command line to do the same work.
With the reference from here and here, I got:
msbuild .\MyProject.sln /p:AppxBundle=Always /p:AppxBundlePlatforms="x86|x64" /p:Configuration=Debug
But I will get errors for my test projects, like:
MakeAppx : error : Error info: error 80080204: The package with file name "Tests.XXXX.Shared.Uwp_1.0.0.0_x86_Debug.appx" and package full name "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx_1.0.0.0_x86__xxxxxxxxxxx" is not valid in the bundle because it has a different package family name than other packages in the bundle. The expected package name is xxxx-Test.xxxxTestApp....
My guess is that I should not use "Always" for AppxBundle, but I cannot find any document online mentioning how to set this value as "If Needed". I also tried to add "Never" in project properties for the test project, but the command line argument seems to overwrite that.
So my question is: How to exclude a test project from the solution when creating a bundle using msbuild in the command line?
How to exclude a test project from the solution when creating a bundle using msbuild in the command line?
To resolve this issue, you can build the project file directly when you create a bundle using MSBuild in the command line:
msbuild .\YourProjectFile.csproj /p:AppxBundle=Always /p:AppxBundlePlatforms="x86|x64" /p:Configuration=Debug
Alternatively, you can open test project file and add the following properties at the end of the first <PropertyGroup> element to exclude the test project to be included:
<PropertyGroup>
<AppxBundle>Never</AppxBundle>
</PropertyGroup>
Check this thread and the document for some more details.
Hope this helps.
I'm trying to get the Output folder of referenced project in my Wix Visual Studio project, using MsBuild task. But it is failing with following error:
C:\Program Files
(x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(724,5):
error : The OutputPath property is not set for project
'ConsoleApplicatio n1.csproj'. Please check to make sure that you
have specified a valid combination of Configuration and Platform for
this project. Configuration='Release' Platfo rm='x86'. You may be
seeing this message because you are trying to build a project without
a solution file, and have specified a non-default Configuration or
Plat form that doesn't exist for this project.
[C:\Users\fwaheed\Documents\Visual Studio
2015\Projects\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.cspro
j]
Following is the Target calling MsBuild task.
<Target Name="AfterBuild">
<MSBuild
Projects="#(ProjectReference)"
Targets="GetTargetPath"
BuildInParallel="false"
Condition="'%(Name)'=='ConsoleApplication1'" >
<Output TaskParameter="TargetOutputs" ItemName="DependentAssemblies" />
</MSBuild>
</Target>
Please note that same target worked perfectly if it is CSharp project, but failing in Wix project.
Can someone guide how to get ReferencedProjects output dirs in Wix Projects?
Thanks
You can try to see how Wix does it for passing the reference values to candle on build. They're in the wix2010.targets or wix200x.targets file. Unfortunately I don't have the time to really dig into this stuff but the properties these tasks set should still exist to be used in your AfterBuild target.
Just search for "ResolveReferences" in one of those targets files.
You can also just try setting
<OutputPath>somepathhere</OutputPath>
in your csproj file since msbuild is complaining that the property isn't set.
I have a TFS 2013 build xaml workflow, that eventually calls the Microsoft.TeamFoundation.Build.Workflow.Activities.MSBuild activity once for each solution that I want to build. When msbuild.exe is called, it's working directory is the working directory of the current solution being built. I can see this through the 'MSBuildStartupDirectory' property when running msbuild with a 'diagnostic' verbosity.
Unfortunately, I need the working of msbuild.exe to be somewhere else when msbuild.exe starts. This is because I use the MSBuild SonarQube runner that imposes constraints on the directory from which msbuild is called.
I have looked at the 'msbuild' activity and there is no way to control the working directory. Is there another way to control the working directory of this activity?
Its been a while since I edited a build process template but I believe you could use an activity that just executes a command in CMD and provide the full MSBuild command. I'm sure there are tons of variables you will need to setup for this to work.
Instead of editing the build process template have you considered using a PowerShell script in the Post-build script to execute SonarQube?
I still haven't found any way to control the working directory of msbuild. But since I know that the working directory will be the directory of the project being built by msbuild, I created a new proj file at the root of my workspace (where my working directory has to be) and only build this new proj file from my workflow. This new proj file then builds all my other solutions. That way, my working directory is the same for all the solutions being built.
Here is an example of my top level proj file:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<ItemGroup>
<Solutions Include="**\*.sln"/>
</ItemGroup>
<Target Name="Build">
<MSBuild Projects="#(Solutions)" Targets="Build"/>
</Target>
</Project>
But beware that doing this may affect the output directory (OutDir) given to each solution. So you may want to do something like this:
<MSBuild Projects="#(Solutions)" Targets="Build" Properties="OutDir=$(OutDir)..\%(Solutions.Filename)"/>
I have a .sln solution file that references a .csproj project file that has an after build task of something like:
<PropertyGroup>
<PostBuildEvent>
xcopy $(SolutionDir)\dir1\Somefle.xml $(ProjectDir) /Y /I
</PostBuildEvent>
</PropertyGroup>
The solution is built using msbuild with a task like the following:
<Target Name="CompileSolution">
<MSBuild Projects="#(SolutionToBuild)" Targets="Rebuild" Properties="Platform=Any CPU" />
</Target>
Now here's the strange part:
If I:
run the build script (say c:\MyWorkingCopy)
rename the working copy folder (say to c:\YourWorkingCopy)
run the build script again
On step 3, the xcopy will fail, because it will because it will be trying to copy the file from "c:\MyWorkingCopy" - which of course is not where the solution file now resides.
Why does msbuild use the old Solution directory? And is there some way to reset it?
(I am using .NET Framework 3.5)
It may be related to the sln.cache file that is created by msbuild when you build a sln file (it's a temporary proj file built from the sln one), if it is present or if the sln is not modified the sln.cache file may be used... I don't really know but it I think it could help.