msbuild

Copy files from Nuget package to output directory with MsBuild in .csproj and dotnet pack command

孤人 提交于 2020-08-22 11:38:32
问题 Last time I had to find out how to extract some files from a Nuget package in took me at least 6 months but I finally managed to find the solution. The thing is that, this solution assumes I have a .nupkg file and manually add a .targets file to perform the extraction process. Now, things are different: I don't have any .nupgk file, we generate one automatically on our VSTS server using the dotnet pack command. Then we consume the package from our Nuget server We can't afford to take another

msbuild 修改 VisualStudio 文件复制到输出目录的路径

故事扮演 提交于 2020-08-16 16:56:14
在默认的 VisualStudio 可以右击任意的文件,让这个文件在编译时复制到输出目录,但是这个选项将会在复制到输出目录时带上这个文件所在 VisualStudio 的文件夹结构。本文告诉大家几个方法让 VisualStudio 的文件可以在编译时输出到自定义的任意路径 文件夹到文件夹 将整个文件夹内容输出到自定义文件夹可以使用写一个 Target 的方法 如我需要将 VisualStudio 的 dll 文件夹的内容全部输出到输出目录,而不是输出到 输出目录下的 Dll 文件夹,可以使用下面代码 <Target Name="CopyReferenceDll" AfterTargets="Build"> <ItemGroup> <ReferenceDll Include="Dll\*.dll"> </ReferenceDll> </ItemGroup> <Copy SourceFiles="@(ReferenceDll)" DestinationFolder="$(OutputPath)" SkipUnchangedFiles="True"></Copy> </Target> 将上面代码复制到 csproj 文件里面,放在 </Project> 之前就可以做到将 VisualStudio 里面的 Dll 文件夹的 dll 文件复制到输出文件夹 至于需要输出其他文件到其他文件夹的

VisualStudio 命令行编译 build 通过 rebuild 不通过

荒凉一梦 提交于 2020-08-13 00:01:29
在使用命令行编译项目,发现使用 build 可以编译通过,但是通过 rebuild 编译提示找不到项目,明明在对应的文件夹存在项目输出的 dll 文件,但是会提示找不到 在命令行编译的 build 和 rebuild 的不同在于使用 build 会用上次编译的内容,如果没有文件更改,那么这个项目不会重新编译。同时会从缓存拿到项目依赖顺序,获取上次编译的项目信息。而 rebuild 会先执行 clean 清理,会清理缓存重新创建项目依赖顺序 而如果 build 能通过而 rebuild 不能通过,此时请尝试清理整个项目仓库的 bin 和 obj 文件夹。在使用 git 管理的项目可以使用下面命令快速清理 git clean -xdf 在执行上面命令之前请先提交本地文件 清理完成之后再次使用 build 命令,关于 msbuild 命令行请看 MSBuild 常用参数 如果清理完成发现通过 build 命令不通过,注意这里的不通过不是因为 nuget 没还原而没通过,那么证明现在的代码是因为依赖上次编译的内容。此时可以清理完成在 VisualStudio 打开,看错误列表内容 如果清理完成发现通过 build 命令能通过,同时用 rebuild 命令如果没有添加 /m 命令也就是并行编译没有问题,而添加了 /m 命令并行重新编译就不通过,提示某些项目的 dll 找不到

ToolsVersion in Visual Studio 2019

江枫思渺然 提交于 2020-08-10 22:15:24
问题 I am doing the migration of several projects from VS2010 to VS2019. Those projects have Tools Version 4 in their vcxprojs: <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> Target VS is VS2019 v16.5.0, MSBuild version is 16.5.0.12403, so I am trying to set ToolsVersion to 16.5: <Project DefaultTargets="Build" ToolsVersion="16.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> But it seems that MSBuild doesn't like it:

ToolsVersion in Visual Studio 2019

梦想与她 提交于 2020-08-10 22:13:04
问题 I am doing the migration of several projects from VS2010 to VS2019. Those projects have Tools Version 4 in their vcxprojs: <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> Target VS is VS2019 v16.5.0, MSBuild version is 16.5.0.12403, so I am trying to set ToolsVersion to 16.5: <Project DefaultTargets="Build" ToolsVersion="16.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> But it seems that MSBuild doesn't like it:

How to use MSBuild to build multiple platforms

拈花ヽ惹草 提交于 2020-08-09 13:40:31
问题 I am using Visual Studio online build with an MSBuild task. I currently have the following MSBuild Arguments fed to my task: /p:Configuration=Release;AppxBundle=Always;AppxBundlePlatforms="x86|x64|ARM";AppxPackageDir="$(Build.BinariesDirectory)\AppxPackages\\";UapAppxPackageBuildMode=StoreUpload This creates my application in x86 , x64 and ARM . It creates Release version of the libraries in x86 BUT creates Debug version of my libraries in x64 and ARM . When my .appxupload package is creates

How to use MSBuild to build multiple platforms

孤人 提交于 2020-08-09 13:36:20
问题 I am using Visual Studio online build with an MSBuild task. I currently have the following MSBuild Arguments fed to my task: /p:Configuration=Release;AppxBundle=Always;AppxBundlePlatforms="x86|x64|ARM";AppxPackageDir="$(Build.BinariesDirectory)\AppxPackages\\";UapAppxPackageBuildMode=StoreUpload This creates my application in x86 , x64 and ARM . It creates Release version of the libraries in x86 BUT creates Debug version of my libraries in x64 and ARM . When my .appxupload package is creates

How to use MSBuild to build multiple platforms

吃可爱长大的小学妹 提交于 2020-08-09 13:36:11
问题 I am using Visual Studio online build with an MSBuild task. I currently have the following MSBuild Arguments fed to my task: /p:Configuration=Release;AppxBundle=Always;AppxBundlePlatforms="x86|x64|ARM";AppxPackageDir="$(Build.BinariesDirectory)\AppxPackages\\";UapAppxPackageBuildMode=StoreUpload This creates my application in x86 , x64 and ARM . It creates Release version of the libraries in x86 BUT creates Debug version of my libraries in x64 and ARM . When my .appxupload package is creates

MSBuild copy or create file if not exists

我只是一个虾纸丫 提交于 2020-08-07 07:27:04
问题 I have a simple requirement to create a file in the project directory called user.config, but only if it doesn't exist already. First attempt: <Target Name="BeforeBuild"> <ItemGroup> <Line Include="line01"><Text><appSettings></appSettings></Text></Line> <LineText Include="%(Line.Text)" /> </ItemGroup> <WriteLinesToFile File="user.config" Lines="@(LineText)" Overwrite="false" /> </Target> Doesn't work because it appends to file Second attempt: <Target Name="BeforeBuild"> <CreateItem Include=

Delete everything in a directory except for one hidden directory in MSBuild

佐手、 提交于 2020-08-07 06:24:09
问题 What's the best way to delete the entire contents of a directory, except for one (hidden) child directory? Thanks! 回答1: <Target Name="DeleteMe"> <ItemGroup> <DeleteMe Include="$(PathRoot)/FolderToDelete/**/*.*" Exclude="$(PathRoot)/FolderToDelete/DoNotDeleteThisHiddenFolder/**/*.*" /> </ItemGroup> <Delete Files="@(DeleteMe)" /> </Target> 来源: https://stackoverflow.com/questions/10014240/delete-everything-in-a-directory-except-for-one-hidden-directory-in-msbuild