VSTS - releasing environment-specific web.config - azure-devops

I have a web.config.test & web.config.production checked into my project. These get built and released to an on-prem server. I think the Command Line task will work to copy the correct file as web.config but I can't figure out how to resolve to the path, as my build is zipped up. Something like
copy web.config.$(Release.EnvironmentName) web.config
but it fails not being able to find the specified file. I echo out the $(Release.EnvironmentName) and it writes "test" to the log, so that's the correct filename, but not sure what the path would be to the file inside the zip. Any ideas?

You need to extract zip file, then copy files, after that you can archive files.

Related

Traget already exist STM32CUBEIDE

I get this error every Time i try to generate the code from the config .ioc file
Go to C:\Users<USER>\STM32Cube\Repository and extract stm32cube_fw_l0_v1121.zip manually. Or remove zip file, FW folder and generate again.
I did the config of the device config tool in that way and it worked.

Is it possible to rename a file during copy with Nuspec files node

I am currently working on changing our codebase to use Nuget. As part of the process the copying of ressources to the output directory should be moved from postbuild events in the projects to the files tag in the .nuspec file.
For the particular project the ressource was called Resources.resx and is renamed to something more specific during the copy (yes I know great programming - not mine and not my place to change it).
Is it possible to change the filename using the file node in nuspec or do I need to keep a postbuild in this case?
My attemp of renaming it with the target property fails:
< file src="foo/bar.resx" target="foo/foobar.resx"/>
creates the following output:
"foo/foobar.resx/bar.rex"
I found a familiar problem on github but it was rejected due to being posted on a dead branch and not trying to rename a file but change its type.
https://github.com/NuGet/Home/issues/2019
Thanks for the help
This functionality is not built into NuGet. The only conceivable way to do this would be to implement a powershell script (install.ps1) that would handle the rename of both the file and the csproj.
Late to the party, but this looks like it could work:
From: https://learn.microsoft.com/en-us/nuget/reference/nuspec
Renaming a content file in the package
Source file:
ie\css\style.css
.nuspec entry:
<file src="ie\css\style.css" target="Content\css\ie.css" />
Packaged result:
content\css\ie.css
Edit:
I found this post (https://stackoverflow.com/a/45601252/182888) where it says:
Note: The File extension in src and target must match or the specified target will be treated like a directory.
So keep that in mind or it might trip you up.

NAnt using MSBuild

I am using NAnt to build an asp.net mvc 3 project that contains EXT JS. After the code successfully compiles, msbuild attempts to copy the files into the following sub folder "_PublishedWebsites". Unfortunately the build fails and I get the following error:
[msbuild] C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets(177,5):
error MSB3021: Unable to copy file "Scripts\Foobar\extjs\resources\css\ext-all-gray.css" to "build\_PublishedWebsites\Foobar.WebUI\Scripts\Foobar\extjs\resources\css\ext-all-gray.css".
Could not find a part of the path 'Scripts\Foobar\extjs\resources\css\ext-all-gray.css'. [C:\Work\Projects\Foobar\Src\Foobar.WebUI\Foobar.WebUI.csproj]
The files are in the location but the error seems to occur when files have "-" in the name. To confirm this I excluded the files that were causing the build to fail and what do you know, the build works.Any suggestions would be appreciated.
This error message is about output location not input files, I guess. IMO your part of the output path "Scripts\Foobar\extjs\resources\css\" does not exist. Let's say if "css" folder is missing. Do you have some other .css files without '-' chars in resources\css folder? Are they deployed correctly?

Using wildcards for filenames in powershell

I am having a lot of issues trying to automate downloading from an ftp site. I know the folder the file will be in, and I know that it will be a .zip file. However I do not know what the files will be named.
So I have code that works if I know the file name...for example:
$sourceuri = "ftp://myFtpSite/test/myZipFile.zip"
I would like to be able to use wildcards in this string so it will recongize any zip file. So I could write something like
$sourceuri = "ftp://myFtpSite/test/_.zip"
and it would download any zip file in that folder.
I know this question is ancient, but have you considered just using the console app ftp.exe? You can build a text file with commands (such as "mget *.zip" to retrieve all .zip files) and automate the process.
ftp -s:filename

Dynamically add files to visual studio deployment project

I've been desperately looking for the answer to this and I feel I'm missing something obvious.
I need to copy a folder full of data files into the TARGETDIR of my deployment project at compile time. I can see how I would add individual files (ie. right click in File System and go to Add->File) but I have a folder full of data files which constantly get added to. I'd prefer not to have to add the new files each time I compile.
I have tried using a PreBuildEvent to copy the files:
copy $(ProjectDir)..\Data*.* $(TargetDir)Data\
which fails with error code 1 when I build. I can't help but feel I'm missing the point here though. Any suggestions?
Thanks in advance.
Graeme
Went to this route.
Created a new project (deleted the default source file Class1)
Added the files/folders necessary to the project.
Added the project as project output in the installer, choosing the option content files.
This removes the complexity of having to zip/unzip the files as suggested earlier.
Try
xcopy $(ProjectDir)..\Data\*.* $(TargetDir)Data /e /c /i [/f] [/r] /y
/e to ensure tree structure fulfilment (use /s if you want to bypass empty folders)
/c to continue on error (let the build process finish)
/i necessary to create the destination folder if none exists
/y assume "yes" for overwrite in case of previously existing files
[optionnal]
/f if you wanna see the whole pathes resulting from the copy
/r if you want to overwrite even previously copied read-only files
The method is simpler on the project than on files, yes. Beside, on files, it copies only the modified/missing files on each build but forces you to maintain the project on each data pack modification. Depends on the whole data size and the variability of your data pack.
Also beware the remaining files if you remove some from your data pack and rebuild without emptying your target folder.
Good luck.
I solved the problem by a workaround:
Add a build action of packaging entire directory (could be filtered) to a ZIP file.
Add a reference to an empty ZIP file to deployment project.
Add a custom action to deployment project to extract the ZIP to destination folder.
It's simple and stable.
Your error is probably because your path has spaces in it and you don't have the paths in quotes.
ex copy "$(ProjectDir)..\Data*.*" "$(TargetDir)Data\"
I need to do a similar thing. Thinking a custom action...
I found a different workaround for this. I added a web project to my solution that points at the data directory I want included in the deployment project. The web project automatically picks up any new files in the data directory and you can refer to the project content in the deployment project.