20Jan, 2022
How to Fix, “The Target “Clean” Does Not Exist in the Project.” With Your TDS Project When Using Azure Pipelines.
We recently migrated our DevOps instances which involved creating new pipelines, build agents, etc. On first run I started getting errors with the TDS projects that weren't happening on our old local, which weren't too descriptive, as you can see.
Here's just a couple of examples.
##[error]src\Feature\Metadata\Feature.Metadata.Master\Feature.Metadata.Master.scproj: Error MSB4057: The target "Build" does not exist in the project. ##[error]src\Foundation\Inegrations\Foundation.Inegrations.Master\Foundation.Inegrations.Master.scproj: Error MSB4057: The target "Clean" does not exist in the project.
It was a little tricky with this one since the first thing I did was to switch my solution to the release build configuration and run a build, but there were no errors. TDS was fine here, so what's going on?
Looking at the history of our company's resources, we ran on-prem TFS for many years, as mandated by some of our clients. They required no cloud use of any kind, which wasn't too unusual a while back. This meant our build agents were on a local server, but why is this different from an Azure hosted build agent?
As it turns out a member of our IT group had installed the necessary packages in our on-prem server for TDS to run, and Azure won't give you access to install necessary components such as this.
NuGet to the Rescue
One way around this issue is to include the necessary resources for TDS to run in your solution. You can find the necessary files in TDS classic. Let's go through the steps needed to fix this issue.
Download TDS classic and extract the files. In here, you'll see the folder "NuGetPackages", containing HedgehogDevelopment.TDS.6.0.0.34.nupkg and TemplateDiagram.1.2.0.nupkg, named according to whichever version you're running. Copy these files to a folder that makes sense in your solution.
In Visual Studio, go to Tools -> NuGet Package Manager -> Package Manager Settings -> Package Sources and Add a package source which points to the folder you just created. Close this window.
Right click on your solution under Solution Explorer, and choose Manage NuGet Packages for Solution. Here you'll see HedgehogDevelopment.TDS as an option, which should be installed on all TDS projects in your solution.

Once installed I deployed and ran the pipeline again, knowing it would fail for another reason. I guess I wanted to see that what I had just done got us to the next step.
Adding Your License Key
As expected, the next thing I got was an error related to the missing license needed to use TDS.
PowerShell exited with code '1'. GENERATEPACKAGE(0,0): Error : Exception getting license. 'Can't find product key'
The license information needs to be added as a pipeline variable in order to rectify this. Go to your pipeline -> Variables -> Pipeline variables, and add "TDS_Owner" and "TDS_Key". For good measure I also locked the values.
Don't Set the Variables to Secret
So, it's habit to think about security all the time, but you can't set these variables to secret. They'll need to be stored in plain text.

That's it! Once saved run your pipeline to verify the variables did their job, and you should be error free.