Build Action

什么是Build Action? Build Action is how the file relates to the build and deployment processes.

在Visual Studio 2010的Windows Phone工程中, 有多个build action。它们之间有什么区别呢?

buildaction

* None: 此文件不参与编译也不被输出。比如:工程中的文档文件, readme.txt。

* Compile: 参与编译并输出。主要是代码文件。

* Content: 不参与编译,但会被输出。

* Embedded Resource: 此文件被嵌入到主工程生成的DLL或exe中。主要是资源文件。

* ApplicationDefinition: 和Page类似,但只用于Silverlight的启动页面(默认是App.xaml)。

* Page: Silverligh中所有的usercontrol/page/childwindow xaml都属于"Page” build,其它的build action不能将code behind文件和xaml文件连接起来。

* CodeAnalysisDictionary: 自定义的CodeAnalysis字典。(参考http://blogs.msdn.com/b/codeanalysis/archive/2007/08/20/new-for-visual-studio-2008-custom-dictionaries.aspx

* Resource:embeds the file in a shared (by all files in the assembly with similar setting) assembly manifest resource named AppName.g.resources

* SplashScreen: Silverlight的欢迎界面。

* DesignData: Sample data types will be created as faux types. Use this Build Action when the sample data types are not creatable or have read-only properties that you want to defined sample data values for.

* DesignDataWithDesignTimeCreatableTypes: Sample data types will be created using the types defined in the sample data file. Use this Build Action when the sample data types are creatable using their default empty constructor.

* EntityDeploy: 适用于Entity框架。


WPF 图片等路径问题

                                                                                              Leo

在WPF中,如果不注意,就会被路径给弄得晕乎乎的,为什么导入到项目中的图片就是不Copy到Bug目录下呢,为什么在使用的时候回出现找不到路径呢,在网上我淘了一番,还没有看见什么好文章。

经过最近一段时间的路径问题苦恼,今天在系统的学习WPF的时候《Application WPF In Context》无意之间发现了有个非常像的地方,就是设置每个引入的图片的类型为Source,于是我灵感一动,是不是这个原因呢,我于是开始了一番尝试!

 

我打开我的项目,发现里面的图片路径都没有设置成copy ,都是不copy,这个就难怪了,不会自动的copy到项目bug目录下的

 

在往下看的时候,我又发现原来Build action 有许多不同的选项,于是我查看了一下,种类真是不少啊,后来我发现一个选择类型为Embedded Resource ,哈哈,我想的了一个宝贝是的将我所有项目的里面的图片和模板都从新设置了下一....效果不错,由于知道了问题的所在,于是又在网上查询了一番,专门查询Build action 的用法:在博客园淘到了一篇文章,摘取中间的一部分:

 

None: 此文件不参与编译也不被输出。比如:工程中的文档文件, readme.txt。

* Compile: 参与编译并输出。主要是代码文件。

* Content:不参与编译,但会被输出。

* Embedded Resource:此文件被嵌入到主工程生成的DLL或exe中。主要是资源文件。

* ApplicationDefinition: 和Page类似,但只用于Silverlight的启动页面(默认是App.xaml)。

* Page: Silverligh中所有的usercontrol/page/childwindow xaml都属于"Page” build,其它的build action不能将code behind文件和xaml文件连接起来。

* CodeAnalysisDictionary: 自定义的CodeAnalysis字典。(参考http://blogs.msdn.com/b/codeanalysis/archive/2007/08/20/new-for-visual-studio-2008-custom-dictionaries.aspx

* Resource:embeds the file in a shared (by all files in the assembly with similar setting) assembly manifest resource named AppName.g.resources

* SplashScreen: Silverlight的欢迎界面。

* DesignData: Sample data types will be created as faux types. Use this Build Action when the sample data types are not creatable or have read-only properties that you want to defined sample data values for.

* DesignDataWithDesignTimeCreatableTypes: Sample data types will be created using the types defined in the sample data file. Use this Build Action when the sample data types are creatable using their default empty constructor.

* EntityDeploy: 适用于Entity框架。

 

原文:http://www.cnblogs.com/Tealcwu/archive/2010/07/12/1775904.html

 

如果读到这里,你发现你已经弄懂了,其实还有一处应该注意的地方,就是在使用的时候那个在前后台的路径,我的原则是在前天,尽可能的用自己生成的路径:

方法,随便的在某个页面拖一个Image,然后设置其属性,用VS自带的

如下图所示获取一个路径:

 WPF <wbr><wbr>图片等路径问题

然后设置所有的在Xaml中的路径为刚才的路径然后把图片的名字或资源的名字换掉就可以了。

“/xxx.xxx.xxx;component/bin/Debug/Images/xxx.png”。。。 Ok ,接下来我们就可以对这些imagesource之类的都可以用这种路径进行设置,可以防止有错误。

在后台的时候注意,就是用的时候不能够起始用"/"如new BitmapImage(new Uri("Resources/Images/xxx.jpg", UriKind.Relative)

这样就可以取到了。如果加了"/",在VS下路径可能是正确的,但是发布之后就会出现异常错误,找不到路径。

对于其他类似的资源文件不用编译的,都可以通过这样的方法进行设置。

终于给写完了。。。。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

issta

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值