通过cake保存带有修改后属性的内置csproj

问题描述

我通过csproj从预先创建的cake模板动态构建应用程序(预先创建的csproj放置在与构建的应用程序完全不同的文件夹中)。

  • 应用程序和非sdk csproj情况:

我使用以下cake代码

其中templateCsprojFile-是预先创建的csproj,没有填充的TargetFrameworkVersionOutputPathBaseIntermediateOutputPath属性。我通过下面的cake代码配置所有缺失的属性

            MSBuild(templateCsprojFile,new MSBuildSettings
            {
                Configuration = configuration,// Release
                //ArgumentCustomization = args => args.Append($"--preprocess {outputFolder.Combine("test").ToString()}")
            }
            .WithProperty("TargetFrameworkVersion",moniker.Key) // .net framework version
            .WithProperty("OutputPath",outputFolder.ToString()) // bin path
            .WithProperty("BaseIntermediateOutputPath",$"{objPath}/") // obj folder. The BaseIntermediateOutputPath must end with a trailing slash
            //.WithProperty("CleanIntermediate","False") // has no effect
            );  

上面的代码构建了应用程序,并且我看到binobj文件夹在预期的文件夹中,但是是否还可以保存所构建的csproj(所有内容已填充属性(也包含binobj)的最终文件夹中。查看用于构建应用程序csproj

的基础TargetFrameworkVersion(经过修改后包含.exe等)将很有帮助。
  • 应用程序和SDK csproj案例:

与上面类似的情况,但我使用的蛋糕代码略有不同,MsBuild

            var settings = new DotNetCoreBuildSettings
            {
               norestore = false,Configuration = configuration,Environmentvariables = new Dictionary<string,string>
               {
                   { "TargetFramework",moniker.Key },{ "OutputPath",binFolder.Combine(configuration).ToString() },{ "BaseIntermediateOutputPath",$"{objPath}/" } // obj folder. The BaseIntermediateOutputPath must end with a trailing slash                        
               }
            };
            DotNetCoreBuild(templateCsprojFile.ToString(),settings);   

因此,在上述两种情况下,我都修改csproj,这将有助于以某种方式保存修改后的内容,首先进行可能的分析

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)