I had setup the devops flow for one of my client application. It’s woking fine in build and release level. But after some days suddenly my build failed with the following error.
node_modules\uws\build\binding.sln.metaproj(0,0): Error MSB4126: The specified solution configuration "release|any cpu" is invalid. Please specify a valid solution configuration using the Configuration and Platform properties (e.g. MSBuild.exe Solution.sln /p:Configuration=Debug /p:Platform="Any CPU") or leave those properties blank to use the default solution configuration.
Can anyone please tell me how to resolve this issue?
You can use PowerShell tasks to change the .sln file.
Assume if you want to build projects except a website project, then you can remove the website project info in GlobalSection of the .sln file.
Prerequisites:
Get the project ID you want to remove, the formate as ECF93D95-5096-497E-B4B8-83416DABB516.
Then add a PowerShell task before VS build task which build other projects. The script as:
git checkout $(BUILD.SOURCEBRANCHNAME)
(get-content "$(Build.SourcesDirectory)\relative\path\to\solution") -notmatch "{project_ID}.$(BuildConfiguration)" | out-file "$(Build.SourcesDirectory)\relative\path\to\solution"
Such as below example to remove the project ECF93D95-5096-497E-B4B8-83416DABB516 from .sln file:
git checkout $(BUILD.SOURCEBRANCHNAME)
(get-content "$(Build.SourcesDirectory)\ConsoleAppCore\ConsoleAppCore.sln") -notmatch "{ECF93D95-5096-497E-B4B8-83416DABB516}.$(BuildConfiguration)" | out-file "$(Build.SourcesDirectory)\ConsoleAppCore\ConsoleAppCore.sln"
After the VS Build task, you can add another PowerShell task to recovery the changed .slnas the same version in git repo. The script as:
git reset --hard head
For building websit project except other projects, you can use the same way to skip the project for building.
Note: for PowerShell task, please deselect Fail on Standard Error option.
I think the best option is to use multiple solutions which target group of projects together (Partitioned Solution)
Here is link to get more info about it
Partitioned Solution
Also I implement in many open source project, here one of them
Project on GitHub using Partitioned Solution
I had this problem once while using VSTS. I suggest you to use MSBuild arguments directly
Ho to add to MSBuild Arguments:
/p:Configuration=$(BuildConfiguration) /p:Platform="$(BuildPlatform)"
Note: leave Platform and Configuration empty
Related
I have Azure Devops build pipeline and I want to add a step to it which will run a solution Clean task. I'd like to achieve the same behavior as when I press Build->Clean Solution in Visual Studio. The problem is that I haven't found how to do Clean only without a Build after. I looked through predefined build tasks (Visual Studio Build, MSBuild) without success.
How can I do this? I know that I can use a Command Line task to run MSBuild, but I wonder maybe I miss some straightforward solution.
There is an Clean option on the Get Source tab, which could perform different kinds of cleaning of the working directory of your private agent before the build is run:
We could set the value to true to clean the working directory of your private agent. Even if the build is failed.
You could check the document Clean the local repo on the agent for some more details.
If you are using YAML, you could try below script.
jobs:
- job: string # name of the job (A-Z, a-z, 0-9, and underscore)
...
workspace:
clean: outputs | resources | all # what to clean up before the job runs
Check this document YAML schema reference for some details.
Update1
The default work folder is _work, open it, we could see some folder 1,2,3... such as below:
If you create a new pipeline, It will create a new folder under folder _work, each pipelines have their own work folder, the clean button just clean their work folder, it will not clean other work folder.
I have vs solution which contains multiple projects,
And im now configuring CI/CD pipeline for the solution in azure.
There is one project i dont want to be include in release.
Im trying to remove that project in restore and build tasks.
But still it included in restore and build.
if anyone has an idea about this ?
I've tested on my side using build task, the exclude pattern is working as expected, please check the following sample and compare with yours:
Task:
Log:
In my .NET Framework (C#) solution, I use some Roslyn analyzers, whose settings I tuned in an .editorconfig file.
When I build my solution locally in VS 2019, I get no warnings from the analyzers.
When I build the solution in an Azure DevOps pipeline task, Roslyn related warnings are generated:
It seems to me that the DevOps pipeline task ignores the settings in the .editorconfig file. How can I make the pipeline task consider the .editorconfig file settings?
How can I make the pipeline task consider the .editorconfig file
settings?
We don't need to manually set anything about .editorconfig in pipeline, it would work automatically when it's placed under project folder. I've just tested it both in local machine and build pipeline, it should work.
So you should:
1.Navigate to Azure Devops Repos to check if the .editorconfig file exists in same folder with xx.csproj file. Pay attention to the branch you choose, make sure the branch you use to run build pipeline do have the .editorconfig file.
2.Check the content of .editorconfig file, check if it contains statements like this:
# SA1633: File should have header
dotnet_diagnostic.SA1633.severity = none
Your .editorconfig file won't suppress those warnings unless it contains this kind of definitions.
3.Try using different agents, I assume you're using self-agent. Which means you're calling your local VS instance to run the job and maybe there's something wrong with that. I suggest you can try running it with microsoft-hosted agent(choose windows-latest), it works well in my side. Also, update your local VS to latest version if you continue to do it using self-agent.
4.Specify the version of nuget.exe, 4.4.0 is too old. Try using 5.3.1 and above.
Hope all above helps :)
We ran into a similar problem today, and discovered that MSBuild 16.9 prioritizes code analysis ruleset files over .editorconfig files. So if your project refers to a ruleset that sets a rule to be an Error, but your editorconfig changes it to be a suggestion or warning, it will still treat things as an error.
Since Azure DevOps updated the version of MSBuild to 16.9, while we were still using 16.8, we had different behaviors on our local machines than what happened in our build pipeline.
Oddly enough, setting severity to none in the editorconfig file still seems to prevent the analyzer from complaining.
I'd like to check in assemblies to TFS source control after successful project build on TeamCity. Are there any elegant and easy way to do that?
I can create a command line step and run tf.exe with parameters, but then I need to provide credentials to connect to TFS, map the directories and finally do the check in.
The second option is to set up the powershell step, and use one of the cmdlets, but this requires installation of cmdlets on the build machine which I don't want to do.
Have you got any experience in such case? Maybe I can use the credentials used by TeamCity to get the sources, and do not map the directories but use the downloaded structure / sources?
This answers your question but it is not normally a good idea to commit binaries to your source control. You have a couple of choices.
Create a nuget package manually:Nuget Packages can be stored in a
shared folder. You can manually create a package in 5 minutes.
If your other projects are built using teamcity, check out artifact
dependencies in teamcity.
TF.exe commandline tool is the best feasible option for this scenario.
I've managed to get Teamcity running and connecting into bitbucket and the final step I'd like would be to get the MVC 4 project copied into another folder on the server ready for an xcopy deployment onto a web host.
I'm using MSBUILD, as the build agent.
Thanks in advance.
Preferred way is to use publishing targets in MSBuild.
Add new build step with runner type MSBuild
Set Build file path to your web project csproj file
Set Target to Clean;Build;Publish
Set Command line parameters to /p:Configuration=Release;PublishDir=\\your\target\path
Hope this helps.
You could use the CommandLine buildrunner to xcopy.
Personally I would not even copy the result to a different server.
For deployment I would have a deployment project in Teamcity that gets the required artifcat via wget from the Teamcity Rest-Api and uploads it to the hosting provider.
This can also be done in CommandLine buildrunner.
Under general settings
Click "Show advanced options"
Under Artifact Paths you can specify what you would like put under a new folder
**/* => target_directory
Or you can zip up your files and put under a new folder like this
**/* => newfolder/mypackage.zip
See more details here: https://www.jetbrains.com/help/teamcity/2019.2/configuring-general-settings.html#ConfiguringGeneralSettings-ArtifactPaths